Guest User

Untitled

a guest
Apr 23rd, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1. import java.awt.Color;
  2.  
  3. import javax.swing.JButton;
  4. import javax.swing.JColorChooser;
  5. import javax.swing.JFrame;
  6. import javax.swing.JOptionPane;
  7. import javax.swing.JPanel;
  8.  
  9.  
  10. public class ColorChooserGUI extends JPanel{
  11.  
  12. public ColorChooserGUI(){
  13.  
  14.  
  15.  
  16. }
  17.  
  18. public static void main(String[] args) {
  19. // Create a frame
  20. JFrame frame = new JFrame("Text Stats");
  21. frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  22.  
  23.  
  24. // Create an instance of EmailWindow and add it to the frame.
  25.  
  26. frame.setSize(500, 500);
  27. ColorChooserGUI window = new ColorChooserGUI();
  28. frame.setContentPane(window);
  29.  
  30. frame.setVisible(true);
  31.  
  32. int n = 0;
  33. do{
  34. Color c = JColorChooser.showDialog(null, "Choose your color", Color.black);
  35. frame.setBackground(c);
  36. n = JOptionPane.showConfirmDialog(null,
  37. "Would you like to display another color?",
  38. "An Inane Question", JOptionPane.YES_NO_OPTION);
  39.  
  40. } while( n == JOptionPane.YES_OPTION);
  41.  
  42.  
  43. }
  44.  
  45.  
  46. }
Add Comment
Please, Sign In to add comment