Table: optionally paint alternating rows below table if table is smaller than scroll pane (issue #504)

This commit is contained in:
Karl Tauber
2022-05-25 11:18:22 +02:00
parent 90de14d013
commit 58dbccec2d
5 changed files with 108 additions and 13 deletions

View File

@@ -336,6 +336,16 @@ public class FlatComponents2Test
table.setSurrendersFocusOnKeystroke( focusCellEditorCheckBox.isSelected() );
}
private void alternatingRowsChanged() {
UIManager.put( "Table.alternateRowColor", alternatingRowsCheckBox.isSelected() ? Color.orange : null );
table1ScrollPane.repaint();
}
private void paintOutsideAlternateRowsChanged() {
UIManager.put( "Table.paintOutsideAlternateRows", paintOutsideAlternateRowsCheckBox.isSelected() ? true : null );
table1ScrollPane.repaint();
}
private void treeRendererChanged() {
Object sel = treeRendererComboBox.getSelectedItem();
if( !(sel instanceof String) )
@@ -493,8 +503,10 @@ public class FlatComponents2Test
focusCellEditorCheckBox = new JCheckBox();
showVerticalLinesCheckBox = new JCheckBox();
columnSelectionCheckBox = new JCheckBox();
alternatingRowsCheckBox = new JCheckBox();
intercellSpacingCheckBox = new JCheckBox();
rowHeaderCheckBox = new JCheckBox();
paintOutsideAlternateRowsCheckBox = new JCheckBox();
redGridColorCheckBox = new JCheckBox();
tableHeaderButtonCheckBox = new JCheckBox();
@@ -875,6 +887,11 @@ public class FlatComponents2Test
columnSelectionCheckBox.addActionListener(e -> columnSelectionChanged());
tableOptionsPanel.add(columnSelectionCheckBox, "cell 1 2");
//---- alternatingRowsCheckBox ----
alternatingRowsCheckBox.setText("alternating rows");
alternatingRowsCheckBox.addActionListener(e -> alternatingRowsChanged());
tableOptionsPanel.add(alternatingRowsCheckBox, "cell 2 2");
//---- intercellSpacingCheckBox ----
intercellSpacingCheckBox.setText("intercell spacing");
intercellSpacingCheckBox.addActionListener(e -> intercellSpacingChanged());
@@ -885,6 +902,11 @@ public class FlatComponents2Test
rowHeaderCheckBox.addActionListener(e -> rowHeaderChanged());
tableOptionsPanel.add(rowHeaderCheckBox, "cell 1 3");
//---- paintOutsideAlternateRowsCheckBox ----
paintOutsideAlternateRowsCheckBox.setText("outside alternating rows");
paintOutsideAlternateRowsCheckBox.addActionListener(e -> paintOutsideAlternateRowsChanged());
tableOptionsPanel.add(paintOutsideAlternateRowsCheckBox, "cell 2 3");
//---- redGridColorCheckBox ----
redGridColorCheckBox.setText("red grid color");
redGridColorCheckBox.addActionListener(e -> redGridColorChanged());
@@ -927,8 +949,10 @@ public class FlatComponents2Test
private JCheckBox focusCellEditorCheckBox;
private JCheckBox showVerticalLinesCheckBox;
private JCheckBox columnSelectionCheckBox;
private JCheckBox alternatingRowsCheckBox;
private JCheckBox intercellSpacingCheckBox;
private JCheckBox rowHeaderCheckBox;
private JCheckBox paintOutsideAlternateRowsCheckBox;
private JCheckBox redGridColorCheckBox;
private JCheckBox tableHeaderButtonCheckBox;
// JFormDesigner - End of variables declaration //GEN-END:variables

View File

@@ -1,4 +1,4 @@
JFDML JFormDesigner: "7.0.5.0.382" Java: "16" encoding: "UTF-8"
JFDML JFormDesigner: "7.0.5.0.404" Java: "17.0.2" encoding: "UTF-8"
new FormModel {
contentType: "form/swing"
@@ -485,6 +485,16 @@ new FormModel {
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 2"
} )
add( new FormComponent( "javax.swing.JCheckBox" ) {
name: "alternatingRowsCheckBox"
"text": "alternating rows"
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "alternatingRowsChanged", false ) )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 2 2"
} )
add( new FormComponent( "javax.swing.JCheckBox" ) {
name: "intercellSpacingCheckBox"
"text": "intercell spacing"
@@ -505,6 +515,16 @@ new FormModel {
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 3"
} )
add( new FormComponent( "javax.swing.JCheckBox" ) {
name: "paintOutsideAlternateRowsCheckBox"
"text": "outside alternating rows"
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "paintOutsideAlternateRowsChanged", false ) )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 2 3"
} )
add( new FormComponent( "javax.swing.JCheckBox" ) {
name: "redGridColorCheckBox"
"text": "red grid color"