1 package org.apache.ojb.tools.mapping.reversedb.gui; 2 3 17 18 23 public class JDlgDBConnection extends javax.swing.JDialog { 24 25 JFrmMainFrame mainFrame; 26 27 public JDlgDBConnection(java.awt.Frame parent, boolean modal, 28 JFrmMainFrame aMain) 29 { 30 super(parent, modal); 31 initComponents(); 32 mainFrame = aMain; 33 this.tfJDBCDriver.setText(mainFrame.getProperty(JFrmMainFrame.JDBC_DRIVER, "")); 34 this.tfJDBCURL.setText(mainFrame.getProperty(JFrmMainFrame.JDBC_URL, "")); 35 this.tfUsername.setText(mainFrame.getProperty(JFrmMainFrame.JDBC_USER, "")); 36 this.tfPassword.setText(mainFrame.getProperty(JFrmMainFrame.JDBC_PASSWORD, "")); 37 } 38 39 44 private void initComponents() { 46 java.awt.GridBagConstraints gridBagConstraints; 47 48 lblJDBCDriver = new javax.swing.JLabel (); 49 tfJDBCDriver = new javax.swing.JTextField (); 50 lblJDBCURL = new javax.swing.JLabel (); 51 tfJDBCURL = new javax.swing.JTextField (); 52 lblUsername = new javax.swing.JLabel (); 53 tfUsername = new javax.swing.JTextField (); 54 lblPassword = new javax.swing.JLabel (); 55 tfPassword = new javax.swing.JPasswordField (); 56 jPanel1 = new javax.swing.JPanel (); 57 pbCancel = new javax.swing.JButton (); 58 pbConnect = new javax.swing.JButton (); 59 60 getContentPane().setLayout(new java.awt.GridBagLayout ()); 61 62 addWindowListener(new java.awt.event.WindowAdapter () 63 { 64 public void windowClosing(java.awt.event.WindowEvent evt) 65 { 66 closeDialog(evt); 67 } 68 }); 69 70 lblJDBCDriver.setText("JDBC Driver Class:"); 71 lblJDBCDriver.setLabelFor(tfJDBCDriver); 72 gridBagConstraints = new java.awt.GridBagConstraints (); 73 gridBagConstraints.gridx = 0; 74 gridBagConstraints.gridy = 0; 75 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 76 getContentPane().add(lblJDBCDriver, gridBagConstraints); 77 78 tfJDBCDriver.setText("jTextField1"); 79 gridBagConstraints = new java.awt.GridBagConstraints (); 80 gridBagConstraints.gridx = 1; 81 gridBagConstraints.gridy = 0; 82 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 83 gridBagConstraints.weightx = 1.0; 84 getContentPane().add(tfJDBCDriver, gridBagConstraints); 85 86 lblJDBCURL.setText("JDBC URL:"); 87 gridBagConstraints = new java.awt.GridBagConstraints (); 88 gridBagConstraints.gridx = 0; 89 gridBagConstraints.gridy = 1; 90 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 91 getContentPane().add(lblJDBCURL, gridBagConstraints); 92 93 tfJDBCURL.setColumns(40); 94 tfJDBCURL.setText("jTextField2"); 95 gridBagConstraints = new java.awt.GridBagConstraints (); 96 gridBagConstraints.gridx = 1; 97 gridBagConstraints.gridy = 1; 98 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 99 gridBagConstraints.weightx = 1.0; 100 getContentPane().add(tfJDBCURL, gridBagConstraints); 101 102 lblUsername.setText("Username:"); 103 gridBagConstraints = new java.awt.GridBagConstraints (); 104 gridBagConstraints.gridx = 0; 105 gridBagConstraints.gridy = 2; 106 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 107 getContentPane().add(lblUsername, gridBagConstraints); 108 109 tfUsername.setText("jTextField3"); 110 gridBagConstraints = new java.awt.GridBagConstraints (); 111 gridBagConstraints.gridx = 1; 112 gridBagConstraints.gridy = 2; 113 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 114 gridBagConstraints.weightx = 1.0; 115 getContentPane().add(tfUsername, gridBagConstraints); 116 117 lblPassword.setText("Password:"); 118 gridBagConstraints = new java.awt.GridBagConstraints (); 119 gridBagConstraints.gridx = 0; 120 gridBagConstraints.gridy = 3; 121 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 122 getContentPane().add(lblPassword, gridBagConstraints); 123 124 gridBagConstraints = new java.awt.GridBagConstraints (); 125 gridBagConstraints.gridx = 1; 126 gridBagConstraints.gridy = 3; 127 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 128 gridBagConstraints.weightx = 1.0; 129 getContentPane().add(tfPassword, gridBagConstraints); 130 131 pbCancel.setText("Cancel"); 132 pbCancel.addActionListener(new java.awt.event.ActionListener () 133 { 134 public void actionPerformed(java.awt.event.ActionEvent evt) 135 { 136 pbCancelActionPerformed(evt); 137 } 138 }); 139 140 jPanel1.add(pbCancel); 141 142 pbConnect.setText("Connect"); 143 pbConnect.addActionListener(new java.awt.event.ActionListener () 144 { 145 public void actionPerformed(java.awt.event.ActionEvent evt) 146 { 147 pbConnectActionPerformed(evt); 148 } 149 }); 150 151 jPanel1.add(pbConnect); 152 153 gridBagConstraints = new java.awt.GridBagConstraints (); 154 gridBagConstraints.gridx = 1; 155 gridBagConstraints.gridy = 4; 156 gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST; 157 getContentPane().add(jPanel1, gridBagConstraints); 158 159 pack(); 160 } 162 private void pbCancelActionPerformed (java.awt.event.ActionEvent evt) { dispose(); 166 } 168 private void pbConnectActionPerformed (java.awt.event.ActionEvent evt) { mainFrame.setProperty(JFrmMainFrame.JDBC_DRIVER, tfJDBCDriver.getText()); 172 mainFrame.setProperty(JFrmMainFrame.JDBC_URL, tfJDBCURL.getText()); 173 mainFrame.setProperty(JFrmMainFrame.JDBC_USER, tfUsername.getText()); 174 mainFrame.setProperty(JFrmMainFrame.JDBC_PASSWORD, new String (this.tfPassword.getPassword())); 175 new org.apache.ojb.tools.mapping.reversedb.gui.actions.DBConnectAction(mainFrame).actionPerformed(null); 176 dispose(); 177 } 179 180 private void closeDialog(java.awt.event.WindowEvent evt) { setVisible(false); 182 dispose(); 183 } 185 188 public static void main(String args[]) { 189 } 191 192 193 private javax.swing.JLabel lblJDBCURL; 195 private javax.swing.JLabel lblJDBCDriver; 196 private javax.swing.JPanel jPanel1; 197 private javax.swing.JTextField tfJDBCDriver; 198 private javax.swing.JLabel lblPassword; 199 private javax.swing.JPasswordField tfPassword; 200 private javax.swing.JLabel lblUsername; 201 private javax.swing.JTextField tfUsername; 202 private javax.swing.JButton pbConnect; 203 private javax.swing.JButton pbCancel; 204 private javax.swing.JTextField tfJDBCURL; 205 207 } 208 209 269 | Popular Tags |