Table: fixed inconsistent table selection / move shortcuts (issue #95)

This commit is contained in:
Karl Tauber
2020-05-04 13:30:42 +02:00
parent 514487074b
commit abcce2bf68
5 changed files with 62 additions and 11 deletions

View File

@@ -83,6 +83,14 @@ public class FlatComponents2Test
scrollPane5.setCorner( JScrollPane.UPPER_TRAILING_CORNER, button );
}
private void rowSelectionChanged() {
table1.setRowSelectionAllowed( rowSelectionCheckBox.isSelected() );
}
private void columnSelectionChanged() {
table1.setColumnSelectionAllowed( columnSelectionCheckBox.isSelected() );
}
@SuppressWarnings( { "unchecked", "rawtypes" } )
private void initComponents() {
// JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents
@@ -104,6 +112,8 @@ public class FlatComponents2Test
table1 = new JTable();
dndCheckBox = new JCheckBox();
tableHeaderButtonCheckBox = new JCheckBox();
rowSelectionCheckBox = new JCheckBox();
columnSelectionCheckBox = new JCheckBox();
//======== this ========
setLayout(new MigLayout(
@@ -312,6 +322,17 @@ public class FlatComponents2Test
tableHeaderButtonCheckBox.setText("show button in table header");
tableHeaderButtonCheckBox.addActionListener(e -> tableHeaderButtonChanged());
add(tableHeaderButtonCheckBox, "cell 0 4 3 1");
//---- rowSelectionCheckBox ----
rowSelectionCheckBox.setText("row selection");
rowSelectionCheckBox.setSelected(true);
rowSelectionCheckBox.addActionListener(e -> rowSelectionChanged());
add(rowSelectionCheckBox, "cell 0 4 3 1");
//---- columnSelectionCheckBox ----
columnSelectionCheckBox.setText("column selection");
columnSelectionCheckBox.addActionListener(e -> columnSelectionChanged());
add(columnSelectionCheckBox, "cell 0 4 3 1");
// JFormDesigner - End of component initialization //GEN-END:initComponents
((JComboBox)((DefaultCellEditor)table1.getColumnModel().getColumn( 3 ).getCellEditor()).getComponent()).setEditable( true );
@@ -326,6 +347,8 @@ public class FlatComponents2Test
private JTable table1;
private JCheckBox dndCheckBox;
private JCheckBox tableHeaderButtonCheckBox;
private JCheckBox rowSelectionCheckBox;
private JCheckBox columnSelectionCheckBox;
// JFormDesigner - End of variables declaration //GEN-END:variables
//---- class DummyTransferHandler -----------------------------------------

View File

@@ -1,4 +1,4 @@
JFDML JFormDesigner: "7.0.0.0.194" Java: "13.0.1" encoding: "UTF-8"
JFDML JFormDesigner: "7.0.1.0.272" Java: "13.0.2" encoding: "UTF-8"
new FormModel {
contentType: "form/swing"
@@ -295,6 +295,27 @@ new FormModel {
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 4 3 1"
} )
add( new FormComponent( "javax.swing.JCheckBox" ) {
name: "rowSelectionCheckBox"
"text": "row selection"
"selected": true
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "rowSelectionChanged", false ) )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 4 3 1"
} )
add( new FormComponent( "javax.swing.JCheckBox" ) {
name: "columnSelectionCheckBox"
"text": "column selection"
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "columnSelectionChanged", false ) )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 4 3 1"
} )
}, new FormLayoutConstraints( null ) {
"location": new java.awt.Point( 0, 0 )
"size": new java.awt.Dimension( 790, 715 )

View File

@@ -573,9 +573,9 @@ Table.ancestorInputMap [lazy] 34 javax.swing.plaf.InputMapUIResource
UP selectPreviousRow
shift alt TAB focusHeader
shift DOWN selectNextRowExtendSelection
shift END selectLastColumnExtendSelection
shift END selectLastRowExtendSelection
shift ENTER selectPreviousRowCell
shift HOME selectFirstColumnExtendSelection
shift HOME selectFirstRowExtendSelection
shift KP_DOWN selectNextRowExtendSelection
shift KP_LEFT selectPreviousColumnExtendSelection
shift KP_RIGHT selectNextColumnExtendSelection
@@ -894,7 +894,7 @@ Tree.focusInputMap.RightToLeft [lazy] 12 javax.swing.plaf.InputMapUIResource
shift KP_RIGHT selectParent
shift LEFT selectChild
shift RIGHT selectParent
Tree.focusInputMap [lazy] 27 javax.swing.plaf.InputMapUIResource [UI]
Tree.focusInputMap [lazy] 29 javax.swing.plaf.InputMapUIResource [UI]
alt KP_LEFT selectParent
alt KP_RIGHT selectChild
alt LEFT selectParent
@@ -915,6 +915,8 @@ Tree.focusInputMap [lazy] 27 javax.swing.plaf.InputMapUIResource
RIGHT selectChild
UP selectPrevious
shift DOWN selectNextExtendSelection
shift END selectLastExtendSelection
shift HOME selectFirstExtendSelection
shift KP_DOWN selectNextExtendSelection
shift KP_LEFT selectParent
shift KP_RIGHT selectChild

View File

@@ -583,8 +583,8 @@ Table.ancestorInputMap [lazy] 71 javax.swing.plaf.InputMapUIResource
TAB selectNextColumnCell
UP selectPreviousRow
shift ctrl DOWN selectNextRowExtendSelection
shift ctrl END selectLastRowExtendSelection
shift ctrl HOME selectFirstRowExtendSelection
shift ctrl END selectLastColumnExtendSelection
shift ctrl HOME selectFirstColumnExtendSelection
shift ctrl KP_DOWN selectNextRowExtendSelection
shift ctrl KP_LEFT selectPreviousColumnExtendSelection
shift ctrl KP_RIGHT selectNextColumnExtendSelection
@@ -597,9 +597,9 @@ Table.ancestorInputMap [lazy] 71 javax.swing.plaf.InputMapUIResource
shift ctrl UP selectPreviousRowExtendSelection
shift DELETE cut
shift DOWN selectNextRowExtendSelection
shift END selectLastColumnExtendSelection
shift END selectLastRowExtendSelection
shift ENTER selectPreviousRowCell
shift HOME selectFirstColumnExtendSelection
shift HOME selectFirstRowExtendSelection
shift INSERT paste
shift KP_DOWN selectNextRowExtendSelection
shift KP_LEFT selectPreviousColumnExtendSelection