# HG changeset patch # User Daniele Nicolodi # Date 1322076441 -3600 # Node ID ea3ae6ce9feaccedfbada3b5a794c181f6cda078 # Parent 670905eb688a4c799bb1aa0dad97ace843b95d25 Improved Java interface look. diff -r 670905eb688a -r ea3ae6ce9fea ConnectionManager/src/connectionmanager/DatabaseSelectorDialog.form --- a/ConnectionManager/src/connectionmanager/DatabaseSelectorDialog.form Wed Jun 02 18:02:25 2010 +0200 +++ b/ConnectionManager/src/connectionmanager/DatabaseSelectorDialog.form Wed Nov 23 20:27:21 2011 +0100 @@ -1,13 +1,17 @@ -
+ - + + + + + @@ -23,20 +27,17 @@ - - + + + + - - - - + + + - - - - @@ -45,15 +46,15 @@ - - + + + - - + @@ -83,7 +84,7 @@ - + @@ -93,12 +94,55 @@ - - +
+ + + + + + + + + +
+ + + + + <Editor/> + <Renderer/> + </Column> + <Column maxWidth="-1" minWidth="-1" prefWidth="-1" resizable="true"> + <Title/> + <Editor/> + <Renderer/> + </Column> + <Column maxWidth="-1" minWidth="-1" prefWidth="-1" resizable="true"> + <Title/> + <Editor/> + <Renderer/> + </Column> + </TableColumnModel> + </Property> + <Property name="focusable" type="boolean" value="false"/> + <Property name="gridColor" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> + <Color blue="cc" green="cc" red="cc" type="rgb"/> + </Property> + <Property name="intercellSpacing" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[0, 0]"/> + </Property> + <Property name="rowHeight" type="int" value="24"/> + <Property name="selectionModel" type="javax.swing.ListSelectionModel" editor="org.netbeans.modules.form.editors2.JTableSelectionModelEditor"> + <JTableSelectionModel selectionMode="0"/> + </Property> + <Property name="showVerticalLines" type="boolean" value="false"/> + <Property name="tableHeader" type="javax.swing.table.JTableHeader" editor="org.netbeans.modules.form.editors2.JTableHeaderEditor"> + <TableHeader reorderingAllowed="true" resizingAllowed="true"/> + </Property> </Properties> </Component> </SubComponents> diff -r 670905eb688a -r ea3ae6ce9fea ConnectionManager/src/connectionmanager/DatabaseSelectorDialog.java --- a/ConnectionManager/src/connectionmanager/DatabaseSelectorDialog.java Wed Jun 02 18:02:25 2010 +0200 +++ b/ConnectionManager/src/connectionmanager/DatabaseSelectorDialog.java Wed Nov 23 20:27:21 2011 +0100 @@ -1,9 +1,21 @@ package connectionmanager; +import java.awt.Component; import java.awt.Point; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; +import javax.swing.JLabel; +import javax.swing.JTable; import javax.swing.table.DefaultTableModel; +import javax.swing.table.DefaultTableCellRenderer; + + +class CellRenderer extends DefaultTableCellRenderer { + public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { + return super.getTableCellRendererComponent(table, value, isSelected, false, row, column); + } +} + public class DatabaseSelectorDialog extends javax.swing.JDialog { @@ -15,12 +27,16 @@ public DatabaseSelectorDialog(java.awt.Frame parent) { super(parent, true); initComponents(); + getRootPane().setDefaultButton(selectButton); + databasesTable.setDefaultRenderer(Object.class, new CellRenderer()); databasesTable.addMouseListener(new MouseListenerDoubleClick()); } public DatabaseSelectorDialog() { super(new javax.swing.JFrame(), true); initComponents(); + getRootPane().setDefaultButton(selectButton); + databasesTable.setDefaultRenderer(Object.class, new CellRenderer()); databasesTable.addMouseListener(new MouseListenerDoubleClick()); } @@ -48,11 +64,17 @@ cancelButton = new javax.swing.JButton(); newButton = new javax.swing.JButton(); selectButton = new javax.swing.JButton(); - jScrollPane1 = new javax.swing.JScrollPane(); + scrollPane = new javax.swing.JScrollPane(); databasesTable = new javax.swing.JTable(); setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); - setTitle("Select a connection"); + setTitle("Select database"); + setResizable(false); + addKeyListener(new java.awt.event.KeyAdapter() { + public void keyPressed(java.awt.event.KeyEvent evt) { + formKeyPressed(evt); + } + }); cancelButton.setText("Cancel"); cancelButton.addActionListener(new java.awt.event.ActionListener() { @@ -77,7 +99,14 @@ databasesTable.setModel(new javax.swing.table.DefaultTableModel( new Object [][] { - + {"1", null, null}, + {"2", null, null}, + {"3", null, null}, + {"4", null, null}, + {"5", null, null}, + {"6", null, null}, + {"7", null, null}, + {"8", null, null} }, new String [] { "Hostname", "Database", "Username" @@ -98,37 +127,41 @@ return canEdit [columnIndex]; } }); - jScrollPane1.setViewportView(databasesTable); + databasesTable.setFocusable(false); + databasesTable.setGridColor(new java.awt.Color(204, 204, 204)); + databasesTable.setIntercellSpacing(new java.awt.Dimension(0, 0)); + databasesTable.setRowHeight(24); + databasesTable.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION); + databasesTable.setShowVerticalLines(false); + scrollPane.setViewportView(databasesTable); 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() - .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) - .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup() - .add(183, 183, 183) + .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup() + .addContainerGap() + .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING) + .add(org.jdesktop.layout.GroupLayout.LEADING, scrollPane, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 409, Short.MAX_VALUE) + .add(layout.createSequentialGroup() + .add(newButton, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .add(184, 184, 184) .add(cancelButton, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) - .add(newButton, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) - .add(selectButton, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) - .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup() - .addContainerGap() - .add(jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 400, Short.MAX_VALUE))) + .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED) + .add(selectButton, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))) .addContainerGap()) ); layout.setVerticalGroup( layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup() - .addContainerGap(20, Short.MAX_VALUE) - .add(jScrollPane1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 225, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) - .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) + .addContainerGap() + .add(scrollPane, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 212, Short.MAX_VALUE) + .add(18, 18, 18) .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.CENTER) + .add(newButton) .add(selectButton) - .add(newButton) .add(cancelButton)) - .add(207, 207, 207)) + .addContainerGap()) ); pack(); @@ -161,6 +194,20 @@ } }//GEN-LAST:event_newButtonActionPerformed + private void formKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_formKeyPressed + System.out.printf("key %d is %d\n", evt.getKeyCode(), evt.VK_DOWN); + if (evt.getKeyCode() == evt.VK_DOWN) { + int row = databasesTable.getSelectedRow() + 1; + databasesTable.addRowSelectionInterval(row, row); + return; + } + if (evt.getKeyCode() == evt.VK_UP) { + int row = databasesTable.getSelectedRow() - 1; + databasesTable.addRowSelectionInterval(row, row); + return; + } + }//GEN-LAST:event_formKeyPressed + private void doClose() { setVisible(false); dispose(); @@ -169,13 +216,14 @@ public void add(String hostname, String database, String username) { DefaultTableModel model = (DefaultTableModel) databasesTable.getModel(); model.insertRow(model.getRowCount(), new Object[]{hostname, database, username}); + databasesTable.addRowSelectionInterval(0, 0); } // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton cancelButton; private javax.swing.JTable databasesTable; - private javax.swing.JScrollPane jScrollPane1; private javax.swing.JButton newButton; + private javax.swing.JScrollPane scrollPane; private javax.swing.JButton selectButton; // End of variables declaration//GEN-END:variables }