Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.Color;
- import javax.swing.JButton;
- import javax.swing.JColorChooser;
- import javax.swing.JFrame;
- import javax.swing.JOptionPane;
- import javax.swing.JPanel;
- public class ColorChooserGUI extends JPanel{
- public ColorChooserGUI(){
- }
- public static void main(String[] args) {
- // Create a frame
- JFrame frame = new JFrame("Text Stats");
- frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- // Create an instance of EmailWindow and add it to the frame.
- frame.setSize(500, 500);
- ColorChooserGUI window = new ColorChooserGUI();
- frame.setContentPane(window);
- frame.setVisible(true);
- int n = 0;
- do{
- Color c = JColorChooser.showDialog(null, "Choose your color", Color.black);
- frame.setBackground(c);
- n = JOptionPane.showConfirmDialog(null,
- "Would you like to display another color?",
- "An Inane Question", JOptionPane.YES_NO_OPTION);
- } while( n == JOptionPane.YES_OPTION);
- }
- }
Add Comment
Please, Sign In to add comment