mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2026-02-15 16:27:13 -06:00
Table basic implementation
This commit is contained in:
@@ -0,0 +1,49 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2019 FormDev Software GmbH
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.formdev.flatlaf.ui;
|
||||||
|
|
||||||
|
import javax.swing.JComponent;
|
||||||
|
import javax.swing.LookAndFeel;
|
||||||
|
import javax.swing.plaf.ComponentUI;
|
||||||
|
import javax.swing.plaf.basic.BasicTableUI;
|
||||||
|
import com.formdev.flatlaf.util.UIScale;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides the Flat LaF UI delegate for {@link javax.swing.JTable}.
|
||||||
|
*
|
||||||
|
* TODO document used UI defaults of superclass
|
||||||
|
*
|
||||||
|
* @uiDefault Table.rowHeight int
|
||||||
|
*
|
||||||
|
* @author Karl Tauber
|
||||||
|
*/
|
||||||
|
public class FlatTableUI
|
||||||
|
extends BasicTableUI
|
||||||
|
{
|
||||||
|
public static ComponentUI createUI( JComponent c ) {
|
||||||
|
return new FlatTableUI();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void installDefaults() {
|
||||||
|
super.installDefaults();
|
||||||
|
|
||||||
|
int rowHeight = FlatUIUtils.getUIInt( "Table.rowHeight", 16 );
|
||||||
|
if( rowHeight > 0 )
|
||||||
|
LookAndFeel.installProperty( table, "rowHeight", UIScale.scale( rowHeight ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -169,6 +169,12 @@ TabbedPane.focusColor=3d4b5c
|
|||||||
TabbedPane.contentAreaColor=323232
|
TabbedPane.contentAreaColor=323232
|
||||||
|
|
||||||
|
|
||||||
|
#---- Table ----
|
||||||
|
|
||||||
|
Table.background=@textComponentBackground
|
||||||
|
Table.gridColor=4F5152
|
||||||
|
|
||||||
|
|
||||||
#---- TableHeader ----
|
#---- TableHeader ----
|
||||||
|
|
||||||
TableHeader.background=45494A
|
TableHeader.background=45494A
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ SliderUI=com.formdev.flatlaf.ui.FlatSliderUI
|
|||||||
SpinnerUI=com.formdev.flatlaf.ui.FlatSpinnerUI
|
SpinnerUI=com.formdev.flatlaf.ui.FlatSpinnerUI
|
||||||
SplitPaneUI=com.formdev.flatlaf.ui.FlatSplitPaneUI
|
SplitPaneUI=com.formdev.flatlaf.ui.FlatSplitPaneUI
|
||||||
TabbedPaneUI=com.formdev.flatlaf.ui.FlatTabbedPaneUI
|
TabbedPaneUI=com.formdev.flatlaf.ui.FlatTabbedPaneUI
|
||||||
|
TableUI=com.formdev.flatlaf.ui.FlatTableUI
|
||||||
TableHeaderUI=com.formdev.flatlaf.ui.FlatTableHeaderUI
|
TableHeaderUI=com.formdev.flatlaf.ui.FlatTableHeaderUI
|
||||||
TextAreaUI=com.formdev.flatlaf.ui.FlatTextAreaUI
|
TextAreaUI=com.formdev.flatlaf.ui.FlatTextAreaUI
|
||||||
TextFieldUI=com.formdev.flatlaf.ui.FlatTextFieldUI
|
TextFieldUI=com.formdev.flatlaf.ui.FlatTextFieldUI
|
||||||
@@ -218,6 +219,8 @@ TabbedPane.shadow=@@ComboBox.buttonArrowColor
|
|||||||
|
|
||||||
#---- Table ----
|
#---- Table ----
|
||||||
|
|
||||||
|
Table.rowHeight=20
|
||||||
|
Table.scrollPaneBorder=com.formdev.flatlaf.ui.FlatBorder
|
||||||
Table.ascendingSortIcon=com.formdev.flatlaf.icons.FlatAscendingSortIcon
|
Table.ascendingSortIcon=com.formdev.flatlaf.icons.FlatAscendingSortIcon
|
||||||
Table.descendingSortIcon=com.formdev.flatlaf.icons.FlatDescendingSortIcon
|
Table.descendingSortIcon=com.formdev.flatlaf.icons.FlatDescendingSortIcon
|
||||||
Table.sortIconColor=@icon
|
Table.sortIconColor=@icon
|
||||||
|
|||||||
@@ -169,6 +169,12 @@ TabbedPane.focusColor=dae4ed
|
|||||||
TabbedPane.contentAreaColor=bfbfbf
|
TabbedPane.contentAreaColor=bfbfbf
|
||||||
|
|
||||||
|
|
||||||
|
#---- Table ----
|
||||||
|
|
||||||
|
Table.background=@textComponentBackground
|
||||||
|
Table.gridColor=F7F7F7
|
||||||
|
|
||||||
|
|
||||||
#---- TableHeader ----
|
#---- TableHeader ----
|
||||||
|
|
||||||
TableHeader.background=ffffff
|
TableHeader.background=ffffff
|
||||||
|
|||||||
@@ -178,18 +178,18 @@ public class FlatComponents2Test
|
|||||||
//---- table1 ----
|
//---- table1 ----
|
||||||
table1.setModel(new DefaultTableModel(
|
table1.setModel(new DefaultTableModel(
|
||||||
new Object[][] {
|
new Object[][] {
|
||||||
{"Item 1a", "Item 2a", "January", "July", null},
|
{"Item 1a", "Item 2a", "January", "July", 123, null},
|
||||||
{"Item 1b", "Item 2b", "February", "August", true},
|
{"Item 1b", "Item 2b", "February", "August", 456, true},
|
||||||
},
|
},
|
||||||
new String[] {
|
new String[] {
|
||||||
"Not editable", "Text", "Combo", "Combo Editable", "Boolean"
|
"Not editable", "Text", "Combo", "Combo Editable", "Integer", "Boolean"
|
||||||
}
|
}
|
||||||
) {
|
) {
|
||||||
Class<?>[] columnTypes = new Class<?>[] {
|
Class<?>[] columnTypes = new Class<?>[] {
|
||||||
Object.class, Object.class, String.class, String.class, Boolean.class
|
Object.class, Object.class, String.class, String.class, Integer.class, Boolean.class
|
||||||
};
|
};
|
||||||
boolean[] columnEditable = new boolean[] {
|
boolean[] columnEditable = new boolean[] {
|
||||||
false, true, true, true, true
|
false, true, true, true, true, true
|
||||||
};
|
};
|
||||||
@Override
|
@Override
|
||||||
public Class<?> getColumnClass(int columnIndex) {
|
public Class<?> getColumnClass(int columnIndex) {
|
||||||
|
|||||||
@@ -131,6 +131,7 @@ new FormModel {
|
|||||||
add( "Item 2a" )
|
add( "Item 2a" )
|
||||||
add( "January" )
|
add( "January" )
|
||||||
add( "July" )
|
add( "July" )
|
||||||
|
add( 123 )
|
||||||
add( null )
|
add( null )
|
||||||
} )
|
} )
|
||||||
add( new java.util.Vector {
|
add( new java.util.Vector {
|
||||||
@@ -138,6 +139,7 @@ new FormModel {
|
|||||||
add( "Item 2b" )
|
add( "Item 2b" )
|
||||||
add( "February" )
|
add( "February" )
|
||||||
add( "August" )
|
add( "August" )
|
||||||
|
add( 456 )
|
||||||
add( true )
|
add( true )
|
||||||
} )
|
} )
|
||||||
}, new java.util.Vector {
|
}, new java.util.Vector {
|
||||||
@@ -145,12 +147,14 @@ new FormModel {
|
|||||||
add( "Text" )
|
add( "Text" )
|
||||||
add( "Combo" )
|
add( "Combo" )
|
||||||
add( "Combo Editable" )
|
add( "Combo Editable" )
|
||||||
|
add( "Integer" )
|
||||||
add( "Boolean" )
|
add( "Boolean" )
|
||||||
}, new java.util.Vector {
|
}, new java.util.Vector {
|
||||||
add( null )
|
add( null )
|
||||||
add( null )
|
add( null )
|
||||||
add( class java.lang.String )
|
add( class java.lang.String )
|
||||||
add( class java.lang.String )
|
add( class java.lang.String )
|
||||||
|
add( class java.lang.Integer )
|
||||||
add( class java.lang.Boolean )
|
add( class java.lang.Boolean )
|
||||||
}, new java.util.Vector {
|
}, new java.util.Vector {
|
||||||
add( false )
|
add( false )
|
||||||
@@ -158,12 +162,14 @@ new FormModel {
|
|||||||
add( null )
|
add( null )
|
||||||
add( null )
|
add( null )
|
||||||
add( null )
|
add( null )
|
||||||
|
add( null )
|
||||||
}, new java.util.Vector {
|
}, new java.util.Vector {
|
||||||
add( null )
|
add( null )
|
||||||
add( null )
|
add( null )
|
||||||
add( new com.jformdesigner.model.SwingTableColumn( new java.lang.Object[ "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" ], 0, 0, 0, true ) )
|
add( new com.jformdesigner.model.SwingTableColumn( new java.lang.Object[ "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" ], 0, 0, 0, true ) )
|
||||||
add( new com.jformdesigner.model.SwingTableColumn( new java.lang.Object[ "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" ], 0, 0, 0, true ) )
|
add( new com.jformdesigner.model.SwingTableColumn( new java.lang.Object[ "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" ], 0, 0, 0, true ) )
|
||||||
add( null )
|
add( null )
|
||||||
|
add( null )
|
||||||
} )
|
} )
|
||||||
"autoCreateRowSorter": true
|
"autoCreateRowSorter": true
|
||||||
} )
|
} )
|
||||||
|
|||||||
@@ -181,7 +181,10 @@ TabbedPane.contentAreaColor=bbbbbb
|
|||||||
|
|
||||||
#---- Table ----
|
#---- Table ----
|
||||||
|
|
||||||
|
Table.rowHeight=25
|
||||||
|
Table.background=fffff0
|
||||||
Table.sortIconColor=ffff00
|
Table.sortIconColor=ffff00
|
||||||
|
Table.gridColor=00ffff
|
||||||
|
|
||||||
|
|
||||||
#---- TableHeader ----
|
#---- TableHeader ----
|
||||||
|
|||||||
Reference in New Issue
Block a user