ControlPanel.java



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

/** Control Panel */
public class ControlPanel extends JPanel {

  /** the JTextField object */
    public JTextField field;

  /** the JCheckBox object */
    public JCheckBox valid;

  /** the JCheckBox object */
    public JCheckBox schema;

  /** parent */
    ActionListener parent;

  /** constructor */
    public ControlPanel( ActionListener parent ) {

        this.parent = parent;

        JLabel label = new JLabel( "Input Source:" );
        add(label);
        field = new JTextField( "", 32 );
        add(field);
        valid  = new JCheckBox( "Do Valid", false );
        add(valid);
        schema  = new JCheckBox( "Use Schema", false );
        add(schema);
        JButton button = new JButton( "Load Source" );
        add(button);

        MyAdapter adapter = new MyAdapter();
        field.addActionListener( adapter );
        button.addActionListener( adapter );
    }

  /** return source name */
    public String getSourceName() {

        return field.getText();
    }

  /** do valid or not */
    public boolean doValid() {

        return valid.isSelected();
    }

  /** use schema or not */
    public boolean useSchema() {

        return schema.isSelected();
    }
 
  /** inner class for event handling */
    class MyAdapter implements ActionListener {

         public void actionPerformed( ActionEvent evt ) {

             parent.actionPerformed( evt );
         }
    }

  /** start here(for test) */
    public static void main( String[] argv ) {

        ControlPanel panel = new ControlPanel( null );
        JFrame frame = new JFrame( "Control Panel" );
        frame.getContentPane().add( panel, "Center" );
        frame.pack();
        frame.show();
    }
}