Table: replaced Table.showGrid with Table.showHorizontalLines and Table.showVerticalLines (issue #38)

This commit is contained in:
Karl Tauber
2020-01-09 20:55:55 +01:00
parent 41e2888bf1
commit 43ab095e0f
3 changed files with 23 additions and 18 deletions

View File

@@ -18,6 +18,8 @@ FlatLaf Change Log
- ScrollPane with Table: The border of buttons that are added to one of the four - 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, scroll pane corners are now removed if the center component is a table. Also,
these corner buttons are made not focusable. these corner buttons are made not focusable.
- Table: Replaced `Table.showGrid` with `Table.showHorizontalLines` and
`Table.showVerticalLines`. (issue #38)
## 0.23.1 ## 0.23.1

View File

@@ -56,7 +56,8 @@ import com.formdev.flatlaf.util.UIScale;
* <!-- FlatTableUI --> * <!-- FlatTableUI -->
* *
* @uiDefault Table.rowHeight int * @uiDefault Table.rowHeight int
* @uiDefault Table.showGrid boolean * @uiDefault Table.showHorizontalLines boolean
* @uiDefault Table.showVerticalLines boolean
* @uiDefault Table.intercellSpacing Dimension * @uiDefault Table.intercellSpacing Dimension
* @uiDefault Table.selectionInactiveBackground Color * @uiDefault Table.selectionInactiveBackground Color
* @uiDefault Table.selectionInactiveForeground Color * @uiDefault Table.selectionInactiveForeground Color
@@ -72,7 +73,8 @@ import com.formdev.flatlaf.util.UIScale;
public class FlatTableUI public class FlatTableUI
extends BasicTableUI extends BasicTableUI
{ {
protected boolean showGrid; protected boolean showHorizontalLines;
protected boolean showVerticalLines;
protected Dimension intercellSpacing; protected Dimension intercellSpacing;
protected Color selectionBackground; protected Color selectionBackground;
@@ -102,7 +104,8 @@ public class FlatTableUI
protected void installDefaults() { protected void installDefaults() {
super.installDefaults(); super.installDefaults();
showGrid = UIManager.getBoolean( "Table.showGrid" ); showHorizontalLines = UIManager.getBoolean( "Table.showHorizontalLines" );
showVerticalLines = UIManager.getBoolean( "Table.showVerticalLines" );
intercellSpacing = UIManager.getDimension( "Table.intercellSpacing" ); intercellSpacing = UIManager.getDimension( "Table.intercellSpacing" );
selectionBackground = UIManager.getColor( "Table.selectionBackground" ); selectionBackground = UIManager.getColor( "Table.selectionBackground" );
@@ -116,10 +119,13 @@ public class FlatTableUI
if( rowHeight > 0 ) if( rowHeight > 0 )
LookAndFeel.installProperty( table, "rowHeight", UIScale.scale( rowHeight ) ); LookAndFeel.installProperty( table, "rowHeight", UIScale.scale( rowHeight ) );
if( !showGrid ) { if( !showHorizontalLines ) {
oldShowHorizontalLines = table.getShowHorizontalLines(); oldShowHorizontalLines = table.getShowHorizontalLines();
table.setShowHorizontalLines( false );
}
if( !showVerticalLines ) {
oldShowVerticalLines = table.getShowVerticalLines(); oldShowVerticalLines = table.getShowVerticalLines();
table.setShowGrid( false ); table.setShowVerticalLines( false );
} }
if( intercellSpacing != null ) { if( intercellSpacing != null ) {
@@ -137,19 +143,15 @@ public class FlatTableUI
selectionInactiveBackground = null; selectionInactiveBackground = null;
selectionInactiveForeground = null; selectionInactiveForeground = null;
// restore old show grid // restore old show horizontal/vertical lines (if not modified)
if( !showGrid ) { if( !showHorizontalLines && oldShowHorizontalLines && !table.getShowHorizontalLines() )
if( !table.getShowHorizontalLines() ) table.setShowHorizontalLines( true );
table.setShowHorizontalLines( oldShowHorizontalLines ); if( !showVerticalLines && oldShowVerticalLines && !table.getShowVerticalLines() )
if( !table.getShowVerticalLines() ) table.setShowVerticalLines( true );
table.setShowVerticalLines( oldShowVerticalLines );
}
// restore old intercell spacing // restore old intercell spacing (if not modified)
if( intercellSpacing != null ) { if( intercellSpacing != null && table.getIntercellSpacing().equals( intercellSpacing ) )
if( table.getIntercellSpacing().equals( intercellSpacing ) ) table.setIntercellSpacing( oldIntercellSpacing );
table.setIntercellSpacing( oldIntercellSpacing );
}
} }
@Override @Override

View File

@@ -369,7 +369,8 @@ TabbedPane.shadow=$ComboBox.buttonArrowColor
#---- Table ---- #---- Table ----
Table.rowHeight=20 Table.rowHeight=20
Table.showGrid=false Table.showHorizontalLines=false
Table.showVerticalLines=false
Table.intercellSpacing={dimension}0,0 Table.intercellSpacing={dimension}0,0
Table.scrollPaneBorder=com.formdev.flatlaf.ui.FlatBorder Table.scrollPaneBorder=com.formdev.flatlaf.ui.FlatBorder
Table.ascendingSortIcon=com.formdev.flatlaf.icons.FlatAscendingSortIcon Table.ascendingSortIcon=com.formdev.flatlaf.icons.FlatAscendingSortIcon