1 24 25 package org.objectweb.cjdbc.console.gui.frames; 26 27 import java.awt.Dimension ; 28 import java.awt.GridLayout ; 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 import org.objectweb.cjdbc.console.gui.objects.BackendObject; 41 42 47 public class NewBackendFrame extends JFrame 48 { 49 private JTextField newName; 50 private JTextField newUrl; 51 private JTextField newDriver; 52 private JTextField newLoader; 53 private BackendObject bob; 54 private FrameConfirmKeyListener keyListener; 55 56 61 public BackendObject getBob() 62 { 63 return bob; 64 } 65 70 public void setBob(BackendObject bob) 71 { 72 this.bob = bob; 73 newName.setText(bob.getName()); 74 try 75 { 76 newUrl.setText(bob.getMbean().getURL()); 77 newDriver.setText(bob.getMbean().getDriverClassName()); 78 newLoader.setText(bob.getMbean().getDriverPath()); 79 } 80 catch (Exception e) 81 { 82 e.printStackTrace(); 83 newUrl.setText(""); 84 newDriver.setText(""); 85 newLoader.setText(""); 86 } 87 88 } 89 95 public NewBackendFrame(BackendObject bob,ActionListener listener) 96 { 97 super(GuiTranslate.get("frame.backend.title")); 98 Toolkit toolkit = Toolkit.getDefaultToolkit(); 99 Dimension dim = toolkit.getScreenSize(); 100 int screenHeight = dim.height; 101 int screenWidth = dim.width; 102 int frameWidth = 450; 103 int frameHeight = 450; 104 this.setBounds((screenWidth - frameWidth) / 2, 105 (screenHeight - frameHeight) / 2, frameWidth, frameHeight); 106 this.validate(); 107 this.setVisible(false); 108 this.getContentPane().setLayout(new GridLayout (5,2)); 109 110 JButton optionConfirm = new JButton (GuiTranslate.get("frame.ok")); 111 optionConfirm.setActionCommand(GuiCommands.COMMAND_CREATE_BACKEND_APPROVE); 112 optionConfirm.addActionListener(listener); 113 114 keyListener = new FrameConfirmKeyListener(optionConfirm); 115 this.addKeyListener(keyListener); 116 117 this.getContentPane().add(new JLabel (GuiTranslate.get("frame.backend.new.name"))); 119 newName = new JTextField (0); 120 newName.setAlignmentX(CENTER_ALIGNMENT); 121 newName.setText(""); 122 newName.addKeyListener(keyListener); 123 this.getContentPane().add(newName); 124 125 this.getContentPane().add(new JLabel (GuiTranslate.get("frame.backend.new.url"))); 127 newUrl = new JTextField (0); 128 newUrl.setAlignmentX(CENTER_ALIGNMENT); 129 newUrl.setText(""); 130 newUrl.addKeyListener(keyListener); 131 this.getContentPane().add(newUrl); 132 133 this.getContentPane().add(new JLabel (GuiTranslate.get("frame.backend.new.driver"))); 135 newDriver = new JTextField (0); 136 newDriver.setAlignmentX(CENTER_ALIGNMENT); 137 newDriver.setText(""); 138 newDriver.addKeyListener(keyListener); 139 this.getContentPane().add(newDriver); 140 141 this.getContentPane().add(new JLabel (GuiTranslate.get("frame.backend.new.loader"))); 143 newLoader = new JTextField (0); 144 newLoader.setAlignmentX(CENTER_ALIGNMENT); 145 newLoader.setText(""); 146 newLoader.addKeyListener(keyListener); 147 this.getContentPane().add(newLoader); 148 149 this.getContentPane().add(optionConfirm); 150 151 JButton optionCancel = new JButton (GuiTranslate.get("frame.cancel")); 152 optionCancel.setActionCommand(GuiCommands.COMMAND_CREATE_BACKEND_CANCEL); 153 optionCancel.addActionListener(listener); 154 this.getContentPane().add(optionCancel); 155 156 setBob(bob); 157 this.setVisible(false); 158 this.setDefaultCloseOperation(HIDE_ON_CLOSE); 159 this.validate(); 160 } 161 164 public JTextField getNewDriver() 165 { 166 return newDriver; 167 } 168 171 public JTextField getNewLoader() 172 { 173 return newLoader; 174 } 175 178 public JTextField getNewName() 179 { 180 return newName; 181 } 182 185 public JTextField getNewUrl() 186 { 187 return newUrl; 188 } 189 } 190 191 192 | Popular Tags |