Mercurial > hg > ltpda-connection-manager
comparison ConnectionManager/src/connectionmanager/DatabaseDialog.java @ 5:35f1cfcaa5a9
Add crude Java GUI.
author | Daniele Nicolodi <daniele@science.unitn.it> |
---|---|
date | Wed, 02 Jun 2010 17:29:18 +0200 |
parents | |
children | 670905eb688a |
comparison
equal
deleted
inserted
replaced
4:c706c10a76bd | 5:35f1cfcaa5a9 |
---|---|
1 package connectionmanager; | |
2 | |
3 import javax.swing.DefaultComboBoxModel; | |
4 | |
5 public class DatabaseDialog extends javax.swing.JDialog { | |
6 | |
7 public boolean cancelled = true; | |
8 public String hostname; | |
9 public String database; | |
10 | |
11 public DatabaseDialog(java.awt.Frame parent, boolean modal, String[] hostnames) { | |
12 super(parent, modal); | |
13 initComponents(); | |
14 hostnameCombo.setModel(new DefaultComboBoxModel(hostnames)); | |
15 } | |
16 | |
17 public DatabaseDialog(java.awt.Frame parent, boolean modal) { | |
18 super(new java.awt.Frame(), true); | |
19 initComponents(); | |
20 hostnameCombo.setModel(new DefaultComboBoxModel()); | |
21 } | |
22 | |
23 public DatabaseDialog() { | |
24 super(new java.awt.Frame(), true); | |
25 initComponents(); | |
26 hostnameCombo.setModel(new DefaultComboBoxModel()); | |
27 } | |
28 | |
29 @SuppressWarnings("unchecked") | |
30 // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents | |
31 private void initComponents() { | |
32 | |
33 jLabel10 = new javax.swing.JLabel(); | |
34 jLabel9 = new javax.swing.JLabel(); | |
35 databaseCombo = new javax.swing.JComboBox(); | |
36 okButton = new javax.swing.JButton(); | |
37 cancelButton = new javax.swing.JButton(); | |
38 hostnameCombo = new javax.swing.JComboBox(); | |
39 | |
40 setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); | |
41 setTitle("Repository Connection"); | |
42 setLocationByPlatform(true); | |
43 setModal(true); | |
44 setResizable(false); | |
45 | |
46 jLabel10.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); | |
47 jLabel10.setText("Database:"); | |
48 | |
49 jLabel9.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); | |
50 jLabel9.setText("Hostname:"); | |
51 | |
52 databaseCombo.setEditable(true); | |
53 databaseCombo.addActionListener(new java.awt.event.ActionListener() { | |
54 public void actionPerformed(java.awt.event.ActionEvent evt) { | |
55 databaseComboActionPerformed(evt); | |
56 } | |
57 }); | |
58 | |
59 okButton.setText("Ok"); | |
60 okButton.setSelected(true); | |
61 okButton.addActionListener(new java.awt.event.ActionListener() { | |
62 public void actionPerformed(java.awt.event.ActionEvent evt) { | |
63 okButtonActionPerformed(evt); | |
64 } | |
65 }); | |
66 | |
67 cancelButton.setText("Cancel"); | |
68 cancelButton.addActionListener(new java.awt.event.ActionListener() { | |
69 public void actionPerformed(java.awt.event.ActionEvent evt) { | |
70 cancelButtonActionPerformed(evt); | |
71 } | |
72 }); | |
73 | |
74 hostnameCombo.setEditable(true); | |
75 hostnameCombo.addActionListener(new java.awt.event.ActionListener() { | |
76 public void actionPerformed(java.awt.event.ActionEvent evt) { | |
77 hostnameComboActionPerformed(evt); | |
78 } | |
79 }); | |
80 | |
81 org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane()); | |
82 getContentPane().setLayout(layout); | |
83 layout.setHorizontalGroup( | |
84 layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) | |
85 .add(layout.createSequentialGroup() | |
86 .addContainerGap() | |
87 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) | |
88 .add(layout.createSequentialGroup() | |
89 .add(jLabel9) | |
90 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) | |
91 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) | |
92 .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup() | |
93 .add(cancelButton) | |
94 .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) | |
95 .add(okButton)) | |
96 .add(hostnameCombo, 0, 218, Short.MAX_VALUE))) | |
97 .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup() | |
98 .add(jLabel10) | |
99 .add(11, 11, 11) | |
100 .add(databaseCombo, 0, 218, Short.MAX_VALUE))) | |
101 .addContainerGap()) | |
102 ); | |
103 layout.setVerticalGroup( | |
104 layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) | |
105 .add(layout.createSequentialGroup() | |
106 .addContainerGap() | |
107 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) | |
108 .add(jLabel9) | |
109 .add(hostnameCombo, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) | |
110 .add(18, 18, 18) | |
111 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) | |
112 .add(databaseCombo, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) | |
113 .add(jLabel10)) | |
114 .add(118, 118, 118) | |
115 .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) | |
116 .add(okButton) | |
117 .add(cancelButton)) | |
118 .addContainerGap(34, Short.MAX_VALUE)) | |
119 ); | |
120 | |
121 pack(); | |
122 }// </editor-fold>//GEN-END:initComponents | |
123 | |
124 private void cancelButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelButtonActionPerformed | |
125 cancelled = true; | |
126 doClose(); | |
127 }//GEN-LAST:event_cancelButtonActionPerformed | |
128 | |
129 private void okButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_okButtonActionPerformed | |
130 cancelled = false; | |
131 hostname = (String)hostnameCombo.getSelectedItem(); | |
132 database = (String)databaseCombo.getSelectedItem(); | |
133 doClose(); | |
134 }//GEN-LAST:event_okButtonActionPerformed | |
135 | |
136 private void databaseComboActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_databaseComboActionPerformed | |
137 | |
138 }//GEN-LAST:event_databaseComboActionPerformed | |
139 | |
140 private void hostnameComboActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_hostnameComboActionPerformed | |
141 | |
142 }//GEN-LAST:event_hostnameComboActionPerformed | |
143 | |
144 private void doClose() { | |
145 setVisible(false); | |
146 dispose(); | |
147 } | |
148 | |
149 // Variables declaration - do not modify//GEN-BEGIN:variables | |
150 private javax.swing.JButton cancelButton; | |
151 private javax.swing.JComboBox databaseCombo; | |
152 private javax.swing.JComboBox hostnameCombo; | |
153 private javax.swing.JLabel jLabel10; | |
154 private javax.swing.JLabel jLabel9; | |
155 private javax.swing.JButton okButton; | |
156 // End of variables declaration//GEN-END:variables | |
157 | |
158 } |