use of javax.swing.JColorChooser in project jdk8u_jdk by JetBrains.
the class Test6707406 method test.
private static void test() {
JColorChooser chooser = new JColorChooser();
chooser.getUI().uninstallUI(chooser);
new Test6707406().installUI(chooser);
chooser.getSelectionModel().setSelectedColor(Color.BLUE);
}
use of javax.swing.JColorChooser in project jdk8u_jdk by JetBrains.
the class Test6977726 method init.
public void init() {
JColorChooser chooser = new JColorChooser();
chooser.setPreviewPanel(new JLabel("Text Preview Panel"));
getContentPane().add(chooser);
}
use of javax.swing.JColorChooser in project jdk8u_jdk by JetBrains.
the class Test6348456 method init.
@Override
public void init() {
JButton button = new JButton("Swap models");
button.addActionListener(this);
this.chooser = new JColorChooser(Color.RED);
this.chooser.setSelectionModel(WHITE);
add(BorderLayout.NORTH, button);
add(BorderLayout.CENTER, this.chooser);
}
use of javax.swing.JColorChooser in project jdk8u_jdk by JetBrains.
the class Test7194184 method run.
public void run() {
String title = getClass().getName();
frame = new JFrame(title);
colorChooser = new JColorChooser();
frame.add(colorChooser);
frame.pack();
frame.setVisible(true);
}
use of javax.swing.JColorChooser in project processdash by dtuma.
the class ColorCellEditor method setUpColorEditor.
//Set up the editor for the Color cells.
public static void setUpColorEditor(JTable table) {
//First, set up the button that brings up the dialog.
final JButton button = new JButton("") {
public void setText(String s) {
//Button never shows text -- only color.
}
};
button.setBackground(Color.white);
button.setBorderPainted(false);
button.setMargin(new Insets(0, 0, 0, 0));
//Now create an editor to encapsulate the button, and
//set it up as the editor for all Color cells.
final ColorCellEditor colorEditor = new ColorCellEditor(button);
table.setDefaultEditor(Color.class, colorEditor);
//Set up the dialog that the button brings up.
final JColorChooser colorChooser = new JColorChooser();
ActionListener okListener = new ActionListener() {
public void actionPerformed(ActionEvent e) {
colorEditor.currentColor = colorChooser.getColor();
}
};
final JDialog dialog = JColorChooser.createDialog(button, "Pick a Color", true, colorChooser, okListener, null);
//Here's the code that brings up the dialog.
button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
button.setBackground(colorEditor.currentColor);
colorChooser.setColor(colorEditor.currentColor);
//Without the following line, the dialog comes up
//in the middle of the screen.
//dialog.setLocationRelativeTo(button);
dialog.setVisible(true);
}
});
}
Aggregations