List:
Some checks failed
CI / build (11, ) (push) Has been cancelled
CI / build (17, ) (push) Has been cancelled
CI / build (21, ) (push) Has been cancelled
CI / build (23, ) (push) Has been cancelled
CI / build (8, ) (push) Has been cancelled
CI / snapshot (push) Has been cancelled
CI / release (push) Has been cancelled

- fixed wrong x/width bounds of alternating rows for multi-column lists (PR #939)
- Demo: added "alternating rows" checkboxes to "Data Components" page
This commit is contained in:
Karl Tauber
2024-12-18 12:22:04 +01:00
parent 7027821c00
commit 80ba75fdeb
6 changed files with 214 additions and 31 deletions

View File

@@ -494,6 +494,11 @@ public class FlatComponents2Test
list.setVisibleRowCount( visibleRowCount );
}
private void listAlternatingRowsChanged() {
UIManager.put( "List.alternateRowColor", listAlternatingRowsCheckBox.isSelected() ? Color.YELLOW : null );
FlatLaf.updateUILater();
}
private void treeRendererChanged() {
Object sel = treeRendererComboBox.getSelectedItem();
if( !(sel instanceof String) )
@@ -530,6 +535,11 @@ public class FlatComponents2Test
tree.putClientProperty( FlatClientProperties.TREE_WIDE_CELL_RENDERER, wideCellRenderer );
}
private void treeAlternatingRowsChanged() {
UIManager.put( "Tree.alternateRowColor", treeAlternatingRowsCheckBox.isSelected() ? Color.cyan : null );
FlatLaf.updateUILater();
}
private void treePaintSelectionChanged() {
boolean paintSelection = treePaintSelectionCheckBox.isSelected();
for( JTree tree : allTrees )
@@ -670,12 +680,14 @@ public class FlatComponents2Test
listLayoutOrientationField = new JComboBox<>();
JLabel listVisibleRowCountLabel = new JLabel();
listVisibleRowCountSpinner = new JSpinner();
listAlternatingRowsCheckBox = new JCheckBox();
treeOptionsPanel = new JPanel();
JLabel treeRendererLabel = new JLabel();
treeRendererComboBox = new JComboBox<>();
treeWideSelectionCheckBox = new JCheckBox();
treeWideCellRendererCheckBox = new JCheckBox();
treePaintSelectionCheckBox = new JCheckBox();
treeAlternatingRowsCheckBox = new JCheckBox();
treePaintLinesCheckBox = new JCheckBox();
treeRedLinesCheckBox = new JCheckBox();
treeEditableCheckBox = new JCheckBox();
@@ -737,7 +749,7 @@ public class FlatComponents2Test
// rows
"[]" +
"[grow]" +
"[]" +
"[]0" +
"[]"));
//---- listLabel ----
@@ -780,7 +792,7 @@ public class FlatComponents2Test
// rows
"[]" +
"[grow]" +
"[]" +
"[]0" +
"[]"));
//---- tableLabel ----
@@ -817,7 +829,7 @@ public class FlatComponents2Test
// rows
"[]" +
"[grow]" +
"[]" +
"[]0" +
"[]"));
//---- treeLabel ----
@@ -1006,6 +1018,7 @@ public class FlatComponents2Test
// rows
"[]" +
"[]" +
"[]" +
"[]"));
//---- listRendererLabel ----
@@ -1043,6 +1056,11 @@ public class FlatComponents2Test
listVisibleRowCountSpinner.setModel(new SpinnerNumberModel(8, 0, null, 1));
listVisibleRowCountSpinner.addChangeListener(e -> listVisibleRowCountChanged());
listOptionsPanel.add(listVisibleRowCountSpinner, "cell 1 2");
//---- listAlternatingRowsCheckBox ----
listAlternatingRowsCheckBox.setText("alternating rows");
listAlternatingRowsCheckBox.addActionListener(e -> listAlternatingRowsChanged());
listOptionsPanel.add(listAlternatingRowsCheckBox, "cell 0 3 2 1,alignx left,growx 0");
}
add(listOptionsPanel, "cell 0 4 4 1");
@@ -1096,6 +1114,11 @@ public class FlatComponents2Test
treePaintSelectionCheckBox.addActionListener(e -> treePaintSelectionChanged());
treeOptionsPanel.add(treePaintSelectionCheckBox, "cell 0 2");
//---- treeAlternatingRowsCheckBox ----
treeAlternatingRowsCheckBox.setText("alternating rows");
treeAlternatingRowsCheckBox.addActionListener(e -> treeAlternatingRowsChanged());
treeOptionsPanel.add(treeAlternatingRowsCheckBox, "cell 0 2");
//---- treePaintLinesCheckBox ----
treePaintLinesCheckBox.setText("paint lines");
treePaintLinesCheckBox.addActionListener(e -> treePaintLinesChanged());
@@ -1253,11 +1276,13 @@ public class FlatComponents2Test
private JComboBox<String> listRendererComboBox;
private JComboBox<String> listLayoutOrientationField;
private JSpinner listVisibleRowCountSpinner;
private JCheckBox listAlternatingRowsCheckBox;
private JPanel treeOptionsPanel;
private JComboBox<String> treeRendererComboBox;
private JCheckBox treeWideSelectionCheckBox;
private JCheckBox treeWideCellRendererCheckBox;
private JCheckBox treePaintSelectionCheckBox;
private JCheckBox treeAlternatingRowsCheckBox;
private JCheckBox treePaintLinesCheckBox;
private JCheckBox treeRedLinesCheckBox;
private JCheckBox treeEditableCheckBox;
@@ -1363,7 +1388,7 @@ public class FlatComponents2Test
@Override
public String getElementAt( int index ) {
return (index < 20)
? "item " + (index + 1)
? "item " + (index + 1) + ((index + 1) % 5 == 0 ? " ####" : "")
: "item " + (index + 1) + " " + randomRowString( index );
}
}

View File

@@ -33,7 +33,7 @@ new FormModel {
} )
add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) {
"$columnConstraints": "[fill]"
"$rowConstraints": "[][grow][][]"
"$rowConstraints": "[][grow][]0[]"
"$layoutConstraints": "ltr,insets 0,hidemode 3"
} ) {
name: "panel1"
@@ -95,7 +95,7 @@ new FormModel {
add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) {
"$layoutConstraints": "insets 0,hidemode 3"
"$columnConstraints": "[fill]"
"$rowConstraints": "[][grow][][]"
"$rowConstraints": "[][grow][]0[]"
} ) {
name: "panel3"
"$client.FlatLaf.internal.testing.ignore": true
@@ -146,7 +146,7 @@ new FormModel {
add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) {
"$layoutConstraints": "insets 0,hidemode 3"
"$columnConstraints": "[fill]"
"$rowConstraints": "[][grow][][]"
"$rowConstraints": "[][grow][]0[]"
} ) {
name: "panel2"
"$client.FlatLaf.internal.testing.ignore": true
@@ -385,7 +385,7 @@ new FormModel {
add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) {
"$layoutConstraints": "insets 8,hidemode 3"
"$columnConstraints": "[fill][fill]"
"$rowConstraints": "[][][]"
"$rowConstraints": "[][][][]"
} ) {
name: "listOptionsPanel"
"border": new javax.swing.border.TitledBorder( "JList Control" )
@@ -455,6 +455,16 @@ new FormModel {
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 2"
} )
add( new FormComponent( "javax.swing.JCheckBox" ) {
name: "listAlternatingRowsCheckBox"
"text": "alternating rows"
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "listAlternatingRowsChanged", false ) )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 3 2 1,alignx left,growx 0"
} )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 4 4 1"
} )
@@ -527,6 +537,16 @@ new FormModel {
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 2"
} )
add( new FormComponent( "javax.swing.JCheckBox" ) {
name: "treeAlternatingRowsCheckBox"
"text": "alternating rows"
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "treeAlternatingRowsChanged", false ) )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 0 2"
} )
add( new FormComponent( "javax.swing.JCheckBox" ) {
name: "treePaintLinesCheckBox"
"text": "paint lines"