package gradertool.admin; import javax.swing.*; import java.awt.*; import java.awt.event.*; /** * ServerSetupDisplay */ public class ServerSetupDisplay extends JFrame { /** * Construct this, per the design explained in the class comment. */ public ServerSetupDisplay() { JPanel outerBox = new JPanel(); Box loginBox = Box.createVerticalBox(); Box buttonBox = Box.createHorizontalBox(); Box userBox = Box.createHorizontalBox(); Box passBox = Box.createHorizontalBox(); loginBox.setPreferredSize(new Dimension(300, 200)); setContentPane(outerBox); buttonBox.setAlignmentX(Component.LEFT_ALIGNMENT); // set up class name box JLabel userLabel = new JLabel("Class Name: "); JTextField userTextField = new JTextField(); userLabel.setForeground(Color.black); userTextField.setMaximumSize(new Dimension(200, 25)); userBox.add(userLabel); userBox.add(userTextField); // set up server url box JLabel urlLabel = new JLabel("Server URL: "); JTextField urlField = new JTextField(); urlLabel.setForeground(Color.black); urlField.setMaximumSize(new Dimension(600, 25)); passBox.add(urlLabel); passBox.add(urlField); // set up buttons box (left to right) Button buttonCancel = new Button("Cancel"); buttonCancel.setMaximumSize(new Dimension(100, 35)); buttonBox.add(buttonCancel); Button buttonEmpty = new Button(""); buttonEmpty.setMaximumSize(new Dimension(100, 35)); buttonEmpty.setVisible(false); buttonBox.add(buttonEmpty); Button buttonSubmit = new Button("Submit"); buttonSubmit.setMaximumSize(new Dimension(100, 35)); buttonBox.add(buttonSubmit); // set up box (top to bottom) loginBox.add(Box.createVerticalStrut(25)); loginBox.add(userBox); loginBox.add(Box.createVerticalStrut(25)); loginBox.add(passBox); loginBox.add(Box.createVerticalStrut(25)); loginBox.add(buttonBox); loginBox.add(Box.createVerticalStrut(5)); // set up outer box (top to bottom) outerBox.add(Box.createHorizontalStrut(20)); outerBox.add(loginBox); setTitle("Server Setup - CPE 308"); cancelButtonAction(buttonCancel); loginButtonAction(buttonSubmit); pack(); } /** * Add the 'Cancel' button. */ protected void cancelButtonAction(Button buttonCancel) { buttonCancel.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { ExportUI exportUI = new ExportUI(); exportUI.getExportDisplay().setVisible(true); setVisible(false); } }); } /** * Add the 'Submit' button. */ protected void loginButtonAction(Button buttonLogin) { buttonLogin.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { System.out.println("Server created."); } }); } }