import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

public class ComponentTest extends JFrame implements ActionListener
{
public JTextField writeBox;
public JComboBox myCombo;

public ComponentTest()
   { 
   setSize( 200, 200);
	setLocation( 50, 50);
	setDefaultCloseOperation( EXIT_ON_CLOSE);
	setLayout (new FlowLayout() );
	
	writeBox = new JTextField("                               ");
	add( writeBox );
	writeBox.addActionListener( this );
	
	String names[] = {"one", "two", "three", "four" };
	myCombo = new JComboBox( names );
	add( myCombo );
	myCombo.addActionListener( this );	
		
	setVisible( true );
   }
	
public static void main(String args [])
   {
	ComponentTest app = new ComponentTest();
	}
	
public void actionPerformed( ActionEvent e )
   {
	if (e.getSource() == writeBox)
	   {
    	System.out.println( writeBox.getText() );		
		writeBox.setText( " new text ");
		}
		
	if (e.getSource() == myCombo )
	   {
		System.out.println(  myCombo.getSelectedItem() );
	   }	
		
	} // end actionPerformed

} // end class
