Start Search Contents Index Links About
TestGUI.java
/*
 * Author: Havard Rast Blok
 * E-mail: 
 * Web   : www.rememberjava.com
 */

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

/**
 * Draws a simple GUI with a JComboBox and a JTextField.
 */
public class TestGUI extends JFrame implements ItemListener
{
  private String artists[] {"Astral Projection""Man With No Name""A Reminiscent Drive"};
  
  private Container c;
  private JComboBox comboBox;
  private JTextField textField;

  public TestGUI()
  {
    super"Test GUI" );
    
    //set up GUI
    
    setSize(200150);
    c = getContentPane();
    c.setLayoutnew GridLayout2) );
   
    textField = new JTextField();
    comboBox = new JComboBoxartists );
    comboBox.addItemListenerthis );
    
    c.addtextField );
    c.addcomboBox );
    
    pack();
    show();
  }
  
  public void itemStateChanged(ItemEvent e)
  {
    textField.setText""+e.getItem() );
  }

  public static void mainString [] arg)
  {
    new TestGUI();
  }// end main

}


site: Håvard Rast Blok
mail:
updated: 27 July 2007