package PS7; import javax.swing.*; import java.awt.*; import java.awt.event.*; public class StereoShipPanel extends JPanel implements ActionListener{ JTextField [] textFields; JButton shipStereos, quitButton; SystemFrame mySystemFrame; int numProducts = 6; /** Creates new StereoShipPanel */ public StereoShipPanel(SystemFrame sFrame) { mySystemFrame=sFrame; setLayout(new GridLayout(7,2)); textFields = new JTextField[6]; for (int count = 0; count < numProducts; count++) { textFields[count]= new JTextField(0); add(new JLabel("# of " + count + " to ship ")); add(textFields[count]); } shipStereos = new JButton("Ship Stereos"); add(shipStereos); shipStereos.addActionListener(this); quitButton = new JButton("Quit"); add(quitButton); quitButton.addActionListener(this); } public void actionPerformed(ActionEvent e) { if (e.getSource()==quitButton) System.exit(0); else { int [] shipOrder = new int[6]; for (int count = 0; count<6; count++) { shipOrder[count] = Integer.parseInt(textFields[count].getText()); textFields[count].setText(null); } mySystemFrame.stereosShipped(shipOrder); } } }