import java.awt.BorderLayout;
import java.awt.Font;
import javax.swing.BorderFactory;
import javax.swing.JColorChooser;
import javax.swing.JFrame;
import javax.swing.JLabel;
public class JColorChooserSample {
public static void main(String args[]) {
JFrame frame = new JFrame("JColorChooser Popup");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
final JLabel label = new JLabel("www.java2java.com", JLabel.CENTER);
label.setFont(new Font("Serif", Font.BOLD | Font.ITALIC, 48));
frame.add(label, BorderLayout.SOUTH);
final JColorChooser colorChooser = new JColorChooser(label.getBackground());
colorChooser.setBorder(BorderFactory.createTitledBorder("Pick Foreground Color"));
frame.add(colorChooser, BorderLayout.CENTER);
frame.pack();
frame.setVisible(true);
}
}
|