import javax.swing.*;
import java.awt.*;

/**
 * Display a File chooser, and a Color Chooser
 */

public class Awindow8 extends JFrame 
{
    public static void main(String[] args) 
    {
        new Awindow8("Color");              //instantiate a Color chooser                   
        new Awindow8("File");               //instantiate a FIle chooser                    
    }

    public Awindow8(String type)            //constructor
    {
        setTitle("A " + type + " Chooser JComponent");              
        setSize(430, 360);                              //set window size
        setLocation(120,80);                            //set window position
        setDefaultCloseOperation(EXIT_ON_CLOSE);        //action when you press X   

        Container pane = getContentPane();              //get reference to contentPane

        Color c = new Color(200,255,255);               //create an RGB color
        pane.setBackground(c);                          //set the background color

        if (type.equals("Color"))
        {
            JColorChooser x = new JColorChooser();      //define a color selector
            pane.add(x);                                //add it to the panel
        }
        if (type.equals("File"))
        {
            JFileChooser x  = new JFileChooser();       //define a file selector
            pane.add(x);                                //add it to the panel
        }                       

        setVisible(true);               //make the window visible
    }
}