0% found this document useful (0 votes)
16 views2 pages

Couleur Vue

This document defines a CouleurVue class in Java that provides a color selection panel. The panel contains radio buttons for selecting whether the color will apply to the figure or background, a combo box for selecting a color, and a button to modify the color palette. It imports necessary classes, defines fields to store the UI elements and color data, and includes methods to add listeners to the components and initialize their properties.

Uploaded by

isaacrobert374
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views2 pages

Couleur Vue

This document defines a CouleurVue class in Java that provides a color selection panel. The panel contains radio buttons for selecting whether the color will apply to the figure or background, a combo box for selecting a color, and a button to modify the color palette. It imports necessary classes, defines fields to store the UI elements and color data, and includes methods to add listeners to the components and initialize their properties.

Uploaded by

isaacrobert374
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

import java.awt.

Color;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import java.util.ArrayList;

import javax.swing.BorderFactory;
import javax.swing.ButtonGroup;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.JScrollPane;
import javax.swing.border.TitledBorder;

class CouleurVue extends JPanel {

protected JRadioButton figure, fond;

protected JButton modifpalette;

private ButtonGroup groupe;

String chemin = "." + File.separatorChar + "ressource" + File.separatorChar;

public ArrayList<Color> couleur = new ArrayList<Color>();

protected Modele modele;

public final JComboBox combolor;

private JScrollPane scrollCouleur;

CouleurVue(final Modele mod) {


super();
modele = mod;
combolor = new JComboBox(modele.colorstring.SCouleurs);
scrollCouleur = new JScrollPane(combolor);
setSize(250, 20);
final String titre = "couleur";
setLayout(new FlowLayout());
final TitledBorder titled = BorderFactory.createTitledBorder(titre);
setBorder(titled);
groupe = new ButtonGroup();
figure = new JRadioButton("figure");
figure.setBackground(Color.blue);
figure.setSelected(true);
figure.setOpaque(true);
fond = new JRadioButton("fond");
fond.setBackground(Color.white);
fond.setOpaque(true);
combolor.setRenderer(new MyCellRenderer(modele));
combolor.setSize(120, 30);
combolor.setMaximumRowCount(10);
modifpalette = new JButton("modifier la palette");
modifpalette.addActionListener(new ActionListener() {
public void actionPerformed(final ActionEvent ev) {
final PaletteCoul dialogPallette = new PaletteCoul(modele);
dialogPallette.setVisible(true);
dialogPallette.dispose();
combolor.updateUI();
}
});
groupe.add(figure);
add(figure);
groupe.add(fond);
add(fond);
add(scrollCouleur);
add(modifpalette);

public void addFondListener(final ActionListener a) {


fond.addActionListener(a);
}

public void addFigureListener(final ActionListener a) {


figure.addActionListener(a);
}

public void addCombocolorListener(final ActionListener a) {


combolor.addActionListener(a);
}

You might also like