import java.util.*; import java.applet.*; import java.awt.*; import java.awt.event.*; import javax.swing.*; public class SampleGui extends Applet implements ActionListener { JComboBox teamASelection; JComboBox teamBSelection; JList teamAPlayerSelection; JList teamBPlayerSelection; //////////////////////////////////////////////////////////////////////////// // Method: init() // Builds gui. //////////////////////////////////////////////////////////////////////////// public void init() { // build selector for team A teamASelection = new JComboBox(); teamASelection.addItem("Reds"); teamASelection.addItem("Whitesox"); teamASelection.addItem("Cardinals"); // build selector for team B teamBSelection = new JComboBox(); teamBSelection.addItem("Reds"); teamBSelection.addItem("Whitesox"); teamBSelection.addItem("Cardinals"); // these will be set in the action handler... whenever the user changes // their selection of team A or B, the appropriate combo box will be // filled with the players for that team. teamAPlayerSelection = new JList(new String[] { "Select", "Team", "First" }); //teamAPlayerSelection.setVisibleRowCount(8); teamBPlayerSelection = new JList(new String[] { "Select", "Team", "First" }); //teamBPlayerSelection.setVisibleRowCount(8); // start setting up layout setLayout(new BorderLayout()); JPanel menus = new JPanel(); menus.setLayout(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); // add label for team A c.gridx = 0; c.gridy = 0; c.gridwidth = 1; menus.add(new JLabel("Team A:"), c); // add selector for team A c.gridx = 0; c.gridy = 1; c.gridwidth = 1; c.fill = GridBagConstraints.BOTH; menus.add(teamASelection, c); // add selector for team A players c.gridx = 0; c.gridy = 2; c.gridheight = 3; c.gridwidth = 1; c.fill = GridBagConstraints.BOTH; menus.add(teamAPlayerSelection, c); // add label for team B c.gridx = 0; c.gridy = 5; c.gridheight = 1; c.gridwidth = 1; menus.add(new JLabel("Team B:"), c); // add selector for team B c.gridx = 0; c.gridy = 6; c.gridheight = 1; c.gridwidth = 1; c.fill = GridBagConstraints.BOTH; menus.add(teamBSelection, c); // add selector for team B players c.gridx = 0; c.gridy = 7; c.gridheight = 3; c.gridwidth = 1; c.fill = GridBagConstraints.BOTH; menus.add(teamBPlayerSelection, c); // add the menu built above to the display add("West", menus); } //////////////////////////////////////////////////////////////////////////// // Method: actionPerformed() // Called whenever the user clicks the button. It's responsible for loading // team and player info in the window //////////////////////////////////////////////////////////////////////////// public void actionPerformed(ActionEvent e) { } }