Table: ascendingSortIcon and descendingSortIcon icons added

This commit is contained in:
Karl Tauber
2019-09-02 17:45:29 +02:00
parent 8754ffe1cb
commit d81e07f03a
6 changed files with 118 additions and 0 deletions

View File

@@ -0,0 +1,52 @@
/*
* 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.icons;
import java.awt.Color;
import java.awt.Component;
import java.awt.Graphics2D;
import java.awt.geom.Path2D;
import javax.swing.UIManager;
/**
* "ascendingSort" icon for {@link javax.swing.table.JTableHeader}.
*
* @uiDefault Table.sortIconColor Color
*
* @author Karl Tauber
*/
public class FlatAscendingSortIcon
extends FlatAbstractIcon
{
protected final Color sortIconColor = UIManager.getColor( "Table.sortIconColor" );
public FlatAscendingSortIcon() {
super( 10, 5, null );
}
@Override
protected void paintIcon( Component c, Graphics2D g ) {
Path2D arrow = new Path2D.Float();
arrow.moveTo( 0.5, 5 );
arrow.lineTo( 9.5, 5 );
arrow.lineTo( 5, 0 );
arrow.closePath();
g.setColor( sortIconColor );
g.fill( arrow );
}
}

View File

@@ -0,0 +1,52 @@
/*
* 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.icons;
import java.awt.Color;
import java.awt.Component;
import java.awt.Graphics2D;
import java.awt.geom.Path2D;
import javax.swing.UIManager;
/**
* "descendingSort" icon for {@link javax.swing.table.JTableHeader}.
*
* @uiDefault Table.sortIconColor Color
*
* @author Karl Tauber
*/
public class FlatDescendingSortIcon
extends FlatAbstractIcon
{
protected final Color sortIconColor = UIManager.getColor( "Table.sortIconColor" );
public FlatDescendingSortIcon() {
super( 10, 5, null );
}
@Override
protected void paintIcon( Component c, Graphics2D g ) {
Path2D arrow = new Path2D.Float();
arrow.moveTo( 0.5, 0 );
arrow.lineTo( 9.5, 0 );
arrow.lineTo( 5, 5 );
arrow.closePath();
g.setColor( sortIconColor );
g.fill( arrow );
}
}

View File

@@ -216,6 +216,13 @@ TabbedPane.tabsOverlapBorder=true
TabbedPane.shadow=@@ComboBox.buttonArrowColor
#---- Table ----
Table.ascendingSortIcon=com.formdev.flatlaf.icons.FlatAscendingSortIcon
Table.descendingSortIcon=com.formdev.flatlaf.icons.FlatDescendingSortIcon
Table.sortIconColor=@icon
#---- TableHeader ----
TableHeader.height=25

View File

@@ -233,6 +233,7 @@ public class FlatComponents2Test
"December"
}))));
}
table1.setAutoCreateRowSorter(true);
scrollPane5.setViewportView(table1);
}
add(scrollPane5, "cell 1 4 2 1,growx,width 300");

View File

@@ -165,6 +165,7 @@ new FormModel {
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 )
} )
"autoCreateRowSorter": true
} )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
"value": "cell 1 4 2 1,growx,width 300"

View File

@@ -179,6 +179,11 @@ TabbedPane.focusColor=dddddd
TabbedPane.contentAreaColor=bbbbbb
#---- Table ----
Table.sortIconColor=ffff00
#---- TableHeader ----
TableHeader.background=4444ff