Mercurial > hg > ltpda-connection-manager
view ConnectionManager/src/connectionmanager/DatabaseDialog.java @ 7:ea3ae6ce9fea default tip
Improved Java interface look.
author | Daniele Nicolodi <daniele@grinta.net> |
---|---|
date | Wed, 23 Nov 2011 20:27:21 +0100 |
parents | 670905eb688a |
children |
line wrap: on
line source
package connectionmanager; import javax.swing.DefaultComboBoxModel; public class DatabaseDialog extends javax.swing.JDialog { public boolean cancelled = true; public String hostname; public String database; public DatabaseDialog(java.awt.Frame parent, boolean modal, String[] hostnames) { super(parent, modal); initComponents(); hostnameCombo.setModel(new DefaultComboBoxModel(hostnames)); } public DatabaseDialog(java.awt.Frame parent, boolean modal) { super(new java.awt.Frame(), true); initComponents(); hostnameCombo.setModel(new DefaultComboBoxModel()); } public DatabaseDialog() { super(new java.awt.Frame(), true); initComponents(); hostnameCombo.setModel(new DefaultComboBoxModel()); } @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { jLabel10 = new javax.swing.JLabel(); jLabel9 = new javax.swing.JLabel(); databaseCombo = new javax.swing.JComboBox(); okButton = new javax.swing.JButton(); cancelButton = new javax.swing.JButton(); hostnameCombo = new javax.swing.JComboBox(); setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); setTitle("Repository Connection"); setLocationByPlatform(true); setModal(true); setResizable(false); jLabel10.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); jLabel10.setText("Database:"); jLabel9.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); jLabel9.setText("Hostname:"); databaseCombo.setEditable(true); databaseCombo.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { databaseComboActionPerformed(evt); } }); okButton.setText("Ok"); okButton.setSelected(true); okButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { okButtonActionPerformed(evt); } }); cancelButton.setText("Cancel"); cancelButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { cancelButtonActionPerformed(evt); } }); hostnameCombo.setEditable(true); hostnameCombo.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { hostnameComboActionPerformed(evt); } }); org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(layout.createSequentialGroup() .addContainerGap() .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(layout.createSequentialGroup() .add(jLabel9) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup() .add(cancelButton) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(okButton)) .add(hostnameCombo, 0, 218, Short.MAX_VALUE))) .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup() .add(jLabel10) .add(11, 11, 11) .add(databaseCombo, 0, 218, Short.MAX_VALUE))) .addContainerGap()) ); layout.setVerticalGroup( layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(layout.createSequentialGroup() .addContainerGap() .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) .add(jLabel9) .add(hostnameCombo, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) .add(18, 18, 18) .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) .add(databaseCombo, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .add(jLabel10)) .add(118, 118, 118) .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) .add(okButton) .add(cancelButton)) .addContainerGap(34, Short.MAX_VALUE)) ); pack(); }// </editor-fold>//GEN-END:initComponents private void cancelButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelButtonActionPerformed cancelled = true; doClose(); }//GEN-LAST:event_cancelButtonActionPerformed private void okButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_okButtonActionPerformed cancelled = false; hostname = (String) hostnameCombo.getSelectedItem(); database = (String) databaseCombo.getSelectedItem(); doClose(); }//GEN-LAST:event_okButtonActionPerformed private void databaseComboActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_databaseComboActionPerformed }//GEN-LAST:event_databaseComboActionPerformed private void hostnameComboActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_hostnameComboActionPerformed }//GEN-LAST:event_hostnameComboActionPerformed private void doClose() { setVisible(false); dispose(); } // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton cancelButton; private javax.swing.JComboBox databaseCombo; private javax.swing.JComboBox hostnameCombo; private javax.swing.JLabel jLabel10; private javax.swing.JLabel jLabel9; private javax.swing.JButton okButton; // End of variables declaration//GEN-END:variables }