Compare commits

...

6 Commits
0.30 ... 0.31

18 changed files with 109 additions and 28 deletions

View File

@@ -1,6 +1,15 @@
FlatLaf Change Log
==================
## 0.31
- Focus indication border (or background) no longer hidden when temporary
loosing focus (e.g. showing a popup menu).
- List, Table and Tree: Item selection color of focused components no longer
change from blue to gray when temporary loosing focus (e.g. showing a popup
menu).
## 0.30
- Windows: Fixed rendering of Unicode characters. Previously not all Unicode

View File

@@ -79,7 +79,13 @@ Projects using FlatLaf
- [jclasslib bytecode viewer](https://github.com/ingokegel/jclasslib) 5.5
- [KeyStore Explorer](https://keystore-explorer.org/) 5.4.3
- [OWASP Zed Attack Proxy (ZAP)](https://www.zaproxy.org/) (in weekly releases)
- [XMLmind XML Editor](https://www.xmlmind.com/xmleditor/) 9.3 (commercial)
- [Total Validator](https://www.totalvalidator.com/) 15 (commercial)
- [j-lawyer](https://github.com/jlawyerorg/j-lawyer-org)
- [MegaMek](https://github.com/MegaMek/megamek) v0.47.4 and
[MekHQ](https://github.com/MegaMek/mekhq) v0.47.5
- [GUIslice Builder](https://github.com/ImpulseAdventure/GUIslice-Builder)
0.13.b024
- [Rest Suite](https://github.com/supanadit/restsuite)
- [ControllerBuddy](https://github.com/bwRavencl/ControllerBuddy)
- [SpringRemote](https://github.com/HaleyWang/SpringRemote)
@@ -89,6 +95,8 @@ Projects using FlatLaf
[mendelson AS2](https://mendelson-e-c.com/as2/),
[AS4](https://mendelson-e-c.com/as4/) and
[OFTP2](https://mendelson-e-c.com/oftp2) (commercial)
- [MeteoInfo](https://github.com/meteoinfo/MeteoInfo) 2.1.6
- [lsfusion platform](https://github.com/lsfusion/platform)
- and more...

View File

@@ -14,8 +14,8 @@
* limitations under the License.
*/
val releaseVersion = "0.30"
val developmentVersion = "0.31-SNAPSHOT"
val releaseVersion = "0.31"
val developmentVersion = "0.32-SNAPSHOT"
version = if( java.lang.Boolean.getBoolean( "release" ) ) releaseVersion else developmentVersion

View File

@@ -96,7 +96,7 @@ public class FlatCheckBoxIcon
boolean selected = indeterminate || (c instanceof AbstractButton && ((AbstractButton)c).isSelected());
// paint focused border
if( c.hasFocus() && focusWidth > 0 ) {
if( FlatUIUtils.isPermanentFocusOwner( c ) && focusWidth > 0 ) {
g2.setColor( focusColor );
paintFocusBorder( g2 );
}

View File

@@ -82,7 +82,7 @@ public class FlatHelpButtonIcon
*/
boolean enabled = c.isEnabled();
boolean focused = c.hasFocus();
boolean focused = FlatUIUtils.isPermanentFocusOwner( c );
// paint focused border
if( focused ) {

View File

@@ -119,7 +119,7 @@ public class FlatBorder
JViewport viewport = ((JScrollPane)c).getViewport();
Component view = (viewport != null) ? viewport.getView() : null;
if( view != null ) {
if( view.hasFocus() )
if( FlatUIUtils.isPermanentFocusOwner( view ) )
return true;
if( (view instanceof JTable && ((JTable)view).isEditing()) ||
@@ -133,17 +133,17 @@ public class FlatBorder
return false;
} else if( c instanceof JComboBox && ((JComboBox<?>)c).isEditable() ) {
Component editorComponent = ((JComboBox<?>)c).getEditor().getEditorComponent();
return (editorComponent != null) ? editorComponent.hasFocus() : false;
return (editorComponent != null) ? FlatUIUtils.isPermanentFocusOwner( editorComponent ) : false;
} else if( c instanceof JSpinner ) {
JComponent editor = ((JSpinner)c).getEditor();
if( editor instanceof JSpinner.DefaultEditor ) {
JTextField textField = ((JSpinner.DefaultEditor)editor).getTextField();
if( textField != null )
return textField.hasFocus();
return FlatUIUtils.isPermanentFocusOwner( textField );
}
return false;
} else
return c.hasFocus();
return FlatUIUtils.isPermanentFocusOwner( c );
}
protected boolean isTableCellEditor( Component c ) {

View File

@@ -294,7 +294,9 @@ public class FlatButtonUI
// paint shadow
Color shadowColor = def ? defaultShadowColor : this.shadowColor;
if( !isToolBarButton && shadowColor != null && shadowWidth > 0 && focusWidth > 0 && !c.hasFocus() && c.isEnabled() ) {
if( !isToolBarButton && shadowColor != null && shadowWidth > 0 && focusWidth > 0 &&
!FlatUIUtils.isPermanentFocusOwner( c ) && c.isEnabled() )
{
g2.setColor( shadowColor );
g2.fill( new RoundRectangle2D.Float( focusWidth, focusWidth + UIScale.scale( (float) shadowWidth ),
width - focusWidth * 2, height - focusWidth * 2, arc, arc ) );
@@ -382,7 +384,7 @@ public class FlatButtonUI
if( hoverColor != null && b != null && b.getModel().isRollover() )
return hoverColor;
if( focusedColor != null && c.hasFocus() )
if( focusedColor != null && FlatUIUtils.isPermanentFocusOwner( c ) )
return focusedColor;
return enabledColor;

View File

@@ -81,7 +81,7 @@ public class FlatListUI
selectionInactiveBackground = UIManager.getColor( "List.selectionInactiveBackground" );
selectionInactiveForeground = UIManager.getColor( "List.selectionInactiveForeground" );
toggleSelectionColors( list.hasFocus() );
toggleSelectionColors();
}
@Override
@@ -100,13 +100,13 @@ public class FlatListUI
@Override
public void focusGained( FocusEvent e ) {
super.focusGained( e );
toggleSelectionColors( true );
toggleSelectionColors();
}
@Override
public void focusLost( FocusEvent e ) {
super.focusLost( e );
toggleSelectionColors( false );
toggleSelectionColors();
}
};
}
@@ -120,8 +120,8 @@ public class FlatListUI
* already used in applications. Then either the inactive colors are not used,
* or the application has to be changed to extend a FlatLaf renderer.
*/
private void toggleSelectionColors( boolean focused ) {
if( focused ) {
private void toggleSelectionColors() {
if( FlatUIUtils.isPermanentFocusOwner( list ) ) {
if( list.getSelectionBackground() == selectionInactiveBackground )
list.setSelectionBackground( selectionBackground );
if( list.getSelectionForeground() == selectionInactiveForeground )

View File

@@ -168,7 +168,7 @@ public class FlatPasswordFieldUI
protected void paintCapsLock( Graphics g ) {
JTextComponent c = getComponent();
if( !c.isFocusOwner() ||
if( !FlatUIUtils.isPermanentFocusOwner( c ) ||
!Toolkit.getDefaultToolkit().getLockingKeyState( KeyEvent.VK_CAPS_LOCK ) )
return;

View File

@@ -201,7 +201,7 @@ public class FlatSliderUI
}
if( coloredTrack != null ) {
FlatUIUtils.setColor( g, slider.hasFocus() ? focusColor : (hover ? hoverColor : thumbColor), thumbColor );
FlatUIUtils.setColor( g, FlatUIUtils.isPermanentFocusOwner( slider ) ? focusColor : (hover ? hoverColor : thumbColor), thumbColor );
((Graphics2D)g).fill( coloredTrack );
}
@@ -212,7 +212,7 @@ public class FlatSliderUI
@Override
public void paintThumb( Graphics g ) {
FlatUIUtils.setColor( g, slider.isEnabled()
? (slider.hasFocus() ? focusColor : (hover ? hoverColor : thumbColor))
? (FlatUIUtils.isPermanentFocusOwner( slider ) ? focusColor : (hover ? hoverColor : thumbColor))
: disabledForeground,
thumbColor );

View File

@@ -318,7 +318,7 @@ public class FlatTabbedPaneUI
boolean enabled = tabPane.isEnabled();
g.setColor( enabled && tabPane.isEnabledAt( tabIndex ) && getRolloverTab() == tabIndex
? hoverColor
: (enabled && isSelected && tabPane.hasFocus()
: (enabled && isSelected && FlatUIUtils.isPermanentFocusOwner( tabPane )
? focusColor
: (selectedBackground != null && enabled && isSelected
? selectedBackground

View File

@@ -113,7 +113,7 @@ public class FlatTableUI
selectionInactiveBackground = UIManager.getColor( "Table.selectionInactiveBackground" );
selectionInactiveForeground = UIManager.getColor( "Table.selectionInactiveForeground" );
toggleSelectionColors( table.hasFocus() );
toggleSelectionColors();
int rowHeight = FlatUIUtils.getUIInt( "Table.rowHeight", 16 );
if( rowHeight > 0 )
@@ -160,13 +160,13 @@ public class FlatTableUI
@Override
public void focusGained( FocusEvent e ) {
super.focusGained( e );
toggleSelectionColors( true );
toggleSelectionColors();
}
@Override
public void focusLost( FocusEvent e ) {
super.focusLost( e );
toggleSelectionColors( false );
toggleSelectionColors();
}
};
}
@@ -180,8 +180,8 @@ public class FlatTableUI
* already used in applications. Then either the inactive colors are not used,
* or the application has to be changed to extend a FlatLaf renderer.
*/
private void toggleSelectionColors( boolean focused ) {
if( focused ) {
private void toggleSelectionColors() {
if( FlatUIUtils.isPermanentFocusOwner( table ) ) {
if( table.getSelectionBackground() == selectionInactiveBackground )
table.setSelectionBackground( selectionBackground );
if( table.getSelectionForeground() == selectionInactiveForeground )

View File

@@ -221,7 +221,7 @@ public class FlatTreeUI
TreePath path, int row, boolean isExpanded, boolean hasBeenExpanded, boolean isLeaf )
{
boolean isEditing = (editingComponent != null && editingRow == row);
boolean hasFocus = tree.hasFocus();
boolean hasFocus = FlatUIUtils.isPermanentFocusOwner( tree );
boolean cellHasFocus = hasFocus && (row == getLeadSelectionRow());
boolean isSelected = tree.isRowSelected( row );
boolean isDropRow = isDropRow( row );

View File

@@ -24,6 +24,7 @@ import java.awt.Font;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Insets;
import java.awt.KeyboardFocusManager;
import java.awt.Rectangle;
import java.awt.RenderingHints;
import java.awt.Shape;
@@ -136,6 +137,10 @@ public class FlatUIUtils
return c instanceof JComponent && Boolean.TRUE.equals( ((JComponent)c).getClientProperty( "JComboBox.isTableCellEditor" ) );
}
public static boolean isPermanentFocusOwner( Component c ) {
return (KeyboardFocusManager.getCurrentKeyboardFocusManager().getPermanentFocusOwner() == c);
}
/**
* Sets rendering hints used for painting.
*/

View File

@@ -81,6 +81,11 @@ class DataComponentsPanel
JScrollPane scrollPane5 = new JScrollPane();
table1 = new JTable();
dndCheckBox = new JCheckBox();
JPopupMenu popupMenu2 = new JPopupMenu();
JMenuItem menuItem3 = new JMenuItem();
JMenuItem menuItem4 = new JMenuItem();
JMenuItem menuItem5 = new JMenuItem();
JMenuItem menuItem6 = new JMenuItem();
//======== this ========
setLayout(new MigLayout(
@@ -126,6 +131,7 @@ class DataComponentsPanel
@Override
public String getElementAt(int i) { return values[i]; }
});
list1.setComponentPopupMenu(popupMenu2);
scrollPane1.setViewportView(list1);
}
add(scrollPane1, "cell 1 0,growx");
@@ -198,6 +204,7 @@ class DataComponentsPanel
add(node1);
}
}));
tree1.setComponentPopupMenu(popupMenu2);
scrollPane3.setViewportView(tree1);
}
add(scrollPane3, "cell 1 1,growx");
@@ -287,6 +294,7 @@ class DataComponentsPanel
}))));
}
table1.setAutoCreateRowSorter(true);
table1.setComponentPopupMenu(popupMenu2);
scrollPane5.setViewportView(table1);
}
add(scrollPane5, "cell 1 2 2 1,growx,width 300");
@@ -296,6 +304,27 @@ class DataComponentsPanel
dndCheckBox.setMnemonic('D');
dndCheckBox.addActionListener(e -> dndChanged());
add(dndCheckBox, "cell 0 3 3 1");
//======== popupMenu2 ========
{
//---- menuItem3 ----
menuItem3.setText("Some Action");
popupMenu2.add(menuItem3);
//---- menuItem4 ----
menuItem4.setText("More Action");
popupMenu2.add(menuItem4);
popupMenu2.addSeparator();
//---- menuItem5 ----
menuItem5.setText("No Action");
popupMenu2.add(menuItem5);
//---- menuItem6 ----
menuItem6.setText("Noop Action");
popupMenu2.add(menuItem6);
}
// JFormDesigner - End of component initialization //GEN-END:initComponents
((JComboBox)((DefaultCellEditor)table1.getColumnModel().getColumn( 3 ).getCellEditor()).getComponent()).setEditable( true );

View File

@@ -1,4 +1,4 @@
JFDML JFormDesigner: "7.0.0.0.194" Java: "13.0.1" encoding: "UTF-8"
JFDML JFormDesigner: "7.0.1.0.272" Java: "13.0.2" encoding: "UTF-8"
new FormModel {
contentType: "form/swing"
@@ -39,6 +39,7 @@ new FormModel {
addElement( "item 14" )
addElement( "item 15" )
}
"componentPopupMenu": new FormReference( "popupMenu2" )
auxiliary() {
"JavaCodeGenerator.typeParameters": "String"
"JavaCodeGenerator.variableLocal": false
@@ -143,6 +144,7 @@ new FormModel {
} )
} )
} )
"componentPopupMenu": new FormReference( "popupMenu2" )
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
@@ -299,6 +301,7 @@ new FormModel {
add( null )
} )
"autoCreateRowSorter": true
"componentPopupMenu": new FormReference( "popupMenu2" )
auxiliary() {
"JavaCodeGenerator.variableLocal": false
}
@@ -321,5 +324,29 @@ new FormModel {
"location": new java.awt.Point( 0, 0 )
"size": new java.awt.Dimension( 790, 715 )
} )
add( new FormContainer( "javax.swing.JPopupMenu", new FormLayoutManager( class javax.swing.JPopupMenu ) ) {
name: "popupMenu2"
add( new FormComponent( "javax.swing.JMenuItem" ) {
name: "menuItem3"
"text": "Some Action"
} )
add( new FormComponent( "javax.swing.JMenuItem" ) {
name: "menuItem4"
"text": "More Action"
} )
add( new FormComponent( "javax.swing.JPopupMenu$Separator" ) {
name: "separator1"
} )
add( new FormComponent( "javax.swing.JMenuItem" ) {
name: "menuItem5"
"text": "No Action"
} )
add( new FormComponent( "javax.swing.JMenuItem" ) {
name: "menuItem6"
"text": "Noop Action"
} )
}, new FormLayoutConstraints( null ) {
"location": new java.awt.Point( 0, 740 )
} )
}
}

View File

@@ -216,7 +216,7 @@ public class FlatJideTabbedPaneUI
g.setColor( enabled && _tabPane.isEnabledAt( tabIndex ) &&
(_indexMouseOver == tabIndex || (_closeButtons != null && ((JideTabbedPane.NoFocusButton)_closeButtons[tabIndex]).isMouseOver()))
? hoverColor
: (enabled && isSelected && _tabPane.hasFocus()
: (enabled && isSelected && FlatUIUtils.isPermanentFocusOwner( _tabPane )
? focusColor
: _tabPane.getBackgroundAt( tabIndex )) );
g.fillRect( x, y, w, h );

View File

@@ -20,6 +20,7 @@ import java.awt.Component;
import javax.swing.JTable;
import org.jdesktop.swingx.JXDatePicker;
import com.formdev.flatlaf.ui.FlatRoundBorder;
import com.formdev.flatlaf.ui.FlatUIUtils;
/**
* Border for {@link org.jdesktop.swingx.JXDatePicker}.
@@ -32,7 +33,7 @@ public class FlatDatePickerBorder
@Override
protected boolean isFocused( Component c ) {
if( c instanceof JXDatePicker )
return ((JXDatePicker)c).getEditor().hasFocus();
return FlatUIUtils.isPermanentFocusOwner( ((JXDatePicker)c).getEditor() );
return super.isFocused( c );
}