1 24 25 package org.objectweb.cjdbc.console.gui.frames; 26 27 import java.awt.Dimension ; 28 import java.awt.FlowLayout ; 29 import java.awt.Toolkit ; 30 import java.awt.event.ActionListener ; 31 32 import javax.swing.JButton ; 33 import javax.swing.JFrame ; 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.FrameConfirmKeyListener; 39 import org.objectweb.cjdbc.console.gui.constants.GuiCommands; 40 41 47 public class GuiNewControllerFrame extends JFrame 48 { 49 private JTextField portNumber; 50 private JTextField ipAddressBox; 51 private ActionListener actionListener; 52 private FrameConfirmKeyListener keyListener; 53 54 59 public GuiNewControllerFrame(ActionListener listener) 60 { 61 super(GuiTranslate.get("frame.controller.title")); 62 this.actionListener = listener; 63 Toolkit toolkit = Toolkit.getDefaultToolkit(); 64 Dimension dim = toolkit.getScreenSize(); 65 int screenHeight = dim.height; 66 int screenWidth = dim.width; 67 int frameWidth = 450; 68 int frameHeight = 50; 69 this.setBounds((screenWidth - frameWidth) / 2, 70 (screenHeight - frameHeight) / 2, frameWidth, frameHeight); 71 this.validate(); 72 this.setVisible(false); 73 this.getContentPane().setLayout(new FlowLayout ()); 74 75 JButton optionConfirm = new JButton (GuiTranslate.get("frame.ok")); 76 optionConfirm.setActionCommand(GuiCommands.COMMAND_ADD_CONTROLLER_APPROVE); 77 optionConfirm.addActionListener(actionListener); 78 79 keyListener = new FrameConfirmKeyListener(optionConfirm); 80 this.addKeyListener(keyListener); 81 82 this.getContentPane().add(new JLabel (GuiTranslate.get("frame.controller.host"))); 83 ipAddressBox = new JTextField (0); 84 ipAddressBox.setAlignmentX(CENTER_ALIGNMENT); 85 ipAddressBox.setText("localhost"); 86 ipAddressBox.addActionListener(actionListener); 87 ipAddressBox.addKeyListener(keyListener); 88 this.getContentPane().add(ipAddressBox); 89 90 this.getContentPane().add(new JLabel (GuiTranslate.get("frame.controller.port"))); 91 portNumber = new JTextField (0); 92 portNumber.setAlignmentX(CENTER_ALIGNMENT); 93 portNumber.setText("1090"); 94 portNumber.addActionListener(actionListener); 95 portNumber.addKeyListener(keyListener); 96 this.getContentPane().add(portNumber); 97 98 99 this.getContentPane().add(optionConfirm); 100 101 JButton optionCancel = new JButton (GuiTranslate.get("frame.cancel")); 102 optionCancel.setActionCommand(GuiCommands.COMMAND_ADD_CONTROLLER_CANCEL); 103 optionCancel.addActionListener(actionListener); 104 this.getContentPane().add(optionCancel); 105 106 this.setVisible(false); 107 this.setDefaultCloseOperation(HIDE_ON_CLOSE); 108 this.validate(); 109 } 110 115 public JTextField getIpAddressBox() 116 { 117 return ipAddressBox; 118 } 119 124 public JTextField getPortNumber() 125 { 126 return portNumber; 127 } 128 } 129 | Popular Tags |