/* (non-Javadoc) * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent) */ public void actionPerformed(ActionEvent e) { PopUp popup; if ("Add".equals(e.getActionCommand())) { popup = new PopUp(1, 0); if (popup.text != null && popup.text.length() != 0) { try { if (!control.create_user(popup.text, popup.secondText)) { popup = new PopUp("User Already Exists"); } } catch (IOException e1) { // TODO Auto-generated catch block } } populateUsers(); } else if ("Logout".equals(e.getActionCommand())) { try { JFrame topFrame = (JFrame) SwingUtilities.getWindowAncestor(this); topFrame.setVisible(false); popup = new PopUp(4, 0); if (popup.response == 0) { padre.logout(); } else { topFrame.setVisible(true); } } catch (IOException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } } else { popup = new PopUp(3, 0); if (popup.response == 0) { if (userList.getSelectedValue() == null) // checks to see if the list is empty { } else // deletes the user { try { System.out.println(control.delete_user(userList.getSelectedValue())); } catch (IOException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } } } populateUsers(); } }
/** * A simplified way to see a JPanel or other Container. Pops up a JFrame with specified Container * as the content pane. */ public static JFrame openInJFrame( Container content, int width, int height, String title, Color bgColor) { JFrame frame = new JFrame(title); frame.setBackground(bgColor); content.setBackground(bgColor); frame.setSize(width, height); frame.setContentPane(content); frame.addWindowListener(new ExitListener()); frame.setVisible(true); return (frame); }