diff --git a/CHANGELOG.md b/CHANGELOG.md index 0abc5f73..c8801d51 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,8 @@ FlatLaf Change Log - ScrollPane with Table: The border of buttons that are added to one of the four scroll pane corners are now removed if the center component is a table. Also, these corner buttons are made not focusable. +- Table: Replaced `Table.showGrid` with `Table.showHorizontalLines` and + `Table.showVerticalLines`. (issue #38) ## 0.23.1 diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatTableUI.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatTableUI.java index 3e7c31bb..bee64c09 100644 --- a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatTableUI.java +++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatTableUI.java @@ -56,7 +56,8 @@ import com.formdev.flatlaf.util.UIScale; * * * @uiDefault Table.rowHeight int - * @uiDefault Table.showGrid boolean + * @uiDefault Table.showHorizontalLines boolean + * @uiDefault Table.showVerticalLines boolean * @uiDefault Table.intercellSpacing Dimension * @uiDefault Table.selectionInactiveBackground Color * @uiDefault Table.selectionInactiveForeground Color @@ -72,7 +73,8 @@ import com.formdev.flatlaf.util.UIScale; public class FlatTableUI extends BasicTableUI { - protected boolean showGrid; + protected boolean showHorizontalLines; + protected boolean showVerticalLines; protected Dimension intercellSpacing; protected Color selectionBackground; @@ -102,7 +104,8 @@ public class FlatTableUI protected void installDefaults() { super.installDefaults(); - showGrid = UIManager.getBoolean( "Table.showGrid" ); + showHorizontalLines = UIManager.getBoolean( "Table.showHorizontalLines" ); + showVerticalLines = UIManager.getBoolean( "Table.showVerticalLines" ); intercellSpacing = UIManager.getDimension( "Table.intercellSpacing" ); selectionBackground = UIManager.getColor( "Table.selectionBackground" ); @@ -116,10 +119,13 @@ public class FlatTableUI if( rowHeight > 0 ) LookAndFeel.installProperty( table, "rowHeight", UIScale.scale( rowHeight ) ); - if( !showGrid ) { + if( !showHorizontalLines ) { oldShowHorizontalLines = table.getShowHorizontalLines(); + table.setShowHorizontalLines( false ); + } + if( !showVerticalLines ) { oldShowVerticalLines = table.getShowVerticalLines(); - table.setShowGrid( false ); + table.setShowVerticalLines( false ); } if( intercellSpacing != null ) { @@ -137,19 +143,15 @@ public class FlatTableUI selectionInactiveBackground = null; selectionInactiveForeground = null; - // restore old show grid - if( !showGrid ) { - if( !table.getShowHorizontalLines() ) - table.setShowHorizontalLines( oldShowHorizontalLines ); - if( !table.getShowVerticalLines() ) - table.setShowVerticalLines( oldShowVerticalLines ); - } + // restore old show horizontal/vertical lines (if not modified) + if( !showHorizontalLines && oldShowHorizontalLines && !table.getShowHorizontalLines() ) + table.setShowHorizontalLines( true ); + if( !showVerticalLines && oldShowVerticalLines && !table.getShowVerticalLines() ) + table.setShowVerticalLines( true ); - // restore old intercell spacing - if( intercellSpacing != null ) { - if( table.getIntercellSpacing().equals( intercellSpacing ) ) - table.setIntercellSpacing( oldIntercellSpacing ); - } + // restore old intercell spacing (if not modified) + if( intercellSpacing != null && table.getIntercellSpacing().equals( intercellSpacing ) ) + table.setIntercellSpacing( oldIntercellSpacing ); } @Override diff --git a/flatlaf-core/src/main/resources/com/formdev/flatlaf/FlatLaf.properties b/flatlaf-core/src/main/resources/com/formdev/flatlaf/FlatLaf.properties index 0940c8e1..111ed511 100644 --- a/flatlaf-core/src/main/resources/com/formdev/flatlaf/FlatLaf.properties +++ b/flatlaf-core/src/main/resources/com/formdev/flatlaf/FlatLaf.properties @@ -369,7 +369,8 @@ TabbedPane.shadow=$ComboBox.buttonArrowColor #---- Table ---- Table.rowHeight=20 -Table.showGrid=false +Table.showHorizontalLines=false +Table.showVerticalLines=false Table.intercellSpacing={dimension}0,0 Table.scrollPaneBorder=com.formdev.flatlaf.ui.FlatBorder Table.ascendingSortIcon=com.formdev.flatlaf.icons.FlatAscendingSortIcon