1 24 25 package org.objectweb.cjdbc.console.gui.frames.jmxdesktop; 26 27 import java.awt.BorderLayout ; 28 import java.awt.GridLayout ; 29 import java.awt.event.ActionEvent ; 30 import java.awt.event.ActionListener ; 31 32 import javax.swing.JButton ; 33 import javax.swing.JDialog ; 34 import javax.swing.JLabel ; 35 import javax.swing.JTextField ; 36 37 import org.objectweb.cjdbc.common.i18n.GuiTranslate; 38 import org.objectweb.cjdbc.console.gui.CjdbcGui; 39 import org.objectweb.cjdbc.console.gui.constants.GuiCommands; 40 import org.objectweb.cjdbc.console.gui.constants.GuiConstants; 41 42 48 public class SetSubjectDialog extends JDialog implements ActionListener 49 { 50 51 private JTextField user; 52 private JTextField password; 53 private CjdbcGui gui; 54 55 61 public SetSubjectDialog(CjdbcGui gui) 62 { 63 super(gui, "Set Subject", true); 64 GuiConstants.centerComponent(this, 300, 100); 65 66 this.getContentPane().setLayout(new BorderLayout ()); 67 this.getContentPane().setLayout(new GridLayout (3, 2)); 68 69 user = new JTextField (""); 70 JLabel userLabel = new JLabel ("User"); 71 this.getContentPane().add(userLabel); 72 this.getContentPane().add(user); 73 74 password = new JTextField (""); 75 JLabel passwordLabel = new JLabel ("Password"); 76 this.getContentPane().add(passwordLabel); 77 this.getContentPane().add(password); 78 79 JButton ok = new JButton (GuiTranslate 80 .get("frame.ok")); 81 ok.setActionCommand(GuiCommands.COMMAND_CONFIRM_ACTION); 82 ok.addActionListener(this); 83 this.getContentPane().add(ok); 84 85 JButton cancel = new JButton (GuiTranslate 86 .get("frame.cancel")); 87 cancel.setActionCommand(GuiCommands.COMMAND_CANCEL_ACTION); 88 cancel.addActionListener(this); 89 this.getContentPane().add(cancel); 90 91 this.validate(); 92 this.gui = gui; 93 this.setVisible(true); 94 95 } 96 97 100 public void actionPerformed(ActionEvent e) 101 { 102 if (e.getActionCommand().equalsIgnoreCase( 103 GuiCommands.COMMAND_CONFIRM_ACTION)) 104 { 105 gui.getCurrentJmxClient().setCurrentSubject(user.getText(), 106 password.getText()); 107 this.setVisible(false); 108 } 109 else if (e.getActionCommand().equalsIgnoreCase( 110 GuiCommands.COMMAND_CANCEL_ACTION)) 111 { 112 this.setVisible(false); 113 } 114 } 115 } 116 | Popular Tags |