01: import java.awt.Color;
02: import javax.swing.JFrame;
03: import javax.swing.JOptionPane;
04: 
05: public class ColorViewer
06: {
07:    public static void main(String[] args)
08:    {
09:       JFrame frame = new JFrame();
10: 
11:       final int FRAME_WIDTH = 300;
12:       final int FRAME_HEIGHT = 400;
13: 
14:       frame.setSize(FRAME_WIDTH, FRAME_HEIGHT);
15:       frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
16: 
17:       String input;
18: 
19:       // Ask the user for red, green, blue values
20:    
21:       input = JOptionPane.showInputDialog("red:");
22:       double red = Double.parseDouble(input);
23:       
24:       input = JOptionPane.showInputDialog("green:");
25:       double green = Double.parseDouble(input);
26:       
27:       input = JOptionPane.showInputDialog("blue:");
28:       double blue = Double.parseDouble(input);
29: 
30:       Color fillColor = new Color(
31:             (float) red, (float) green, (float) blue);     
32:       ColoredSquareComponent component 
33:             = new ColoredSquareComponent(fillColor);
34:       frame.add(component);
35: 
36:       frame.setVisible(true);
37:    }
38: }