mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2025-12-06 22:10:54 +03:00
hide focus indicator when the containing window became inactive
This commit is contained in:
@@ -1,6 +1,11 @@
|
|||||||
FlatLaf Change Log
|
FlatLaf Change Log
|
||||||
==================
|
==================
|
||||||
|
|
||||||
|
## Unreleased
|
||||||
|
|
||||||
|
- Hide focus indicator when window is inactive.
|
||||||
|
|
||||||
|
|
||||||
## 0.37
|
## 0.37
|
||||||
|
|
||||||
- Custom window decorations (Windows 10 only; PR #108; issues #47 and #82)
|
- Custom window decorations (Windows 10 only; PR #108; issues #47 and #82)
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
package com.formdev.flatlaf.ui;
|
package com.formdev.flatlaf.ui;
|
||||||
|
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
|
import java.awt.EventQueue;
|
||||||
import java.awt.event.FocusEvent;
|
import java.awt.event.FocusEvent;
|
||||||
import java.awt.event.FocusListener;
|
import java.awt.event.FocusListener;
|
||||||
import javax.swing.JComponent;
|
import javax.swing.JComponent;
|
||||||
@@ -106,7 +107,11 @@ public class FlatListUI
|
|||||||
@Override
|
@Override
|
||||||
public void focusLost( FocusEvent e ) {
|
public void focusLost( FocusEvent e ) {
|
||||||
super.focusLost( e );
|
super.focusLost( e );
|
||||||
toggleSelectionColors();
|
|
||||||
|
// use invokeLater for the case that the window is deactivated
|
||||||
|
EventQueue.invokeLater( () -> {
|
||||||
|
toggleSelectionColors();
|
||||||
|
} );
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ package com.formdev.flatlaf.ui;
|
|||||||
|
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import java.awt.Dimension;
|
import java.awt.Dimension;
|
||||||
|
import java.awt.EventQueue;
|
||||||
import java.awt.event.FocusEvent;
|
import java.awt.event.FocusEvent;
|
||||||
import java.awt.event.FocusListener;
|
import java.awt.event.FocusListener;
|
||||||
import javax.swing.JCheckBox;
|
import javax.swing.JCheckBox;
|
||||||
@@ -174,7 +175,11 @@ public class FlatTableUI
|
|||||||
@Override
|
@Override
|
||||||
public void focusLost( FocusEvent e ) {
|
public void focusLost( FocusEvent e ) {
|
||||||
super.focusLost( e );
|
super.focusLost( e );
|
||||||
toggleSelectionColors();
|
|
||||||
|
// use invokeLater for the case that the window is deactivated
|
||||||
|
EventQueue.invokeLater( () -> {
|
||||||
|
toggleSelectionColors();
|
||||||
|
} );
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ import java.awt.geom.RoundRectangle2D;
|
|||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import javax.swing.JComponent;
|
import javax.swing.JComponent;
|
||||||
import javax.swing.LookAndFeel;
|
import javax.swing.LookAndFeel;
|
||||||
|
import javax.swing.SwingUtilities;
|
||||||
import javax.swing.UIManager;
|
import javax.swing.UIManager;
|
||||||
import javax.swing.border.Border;
|
import javax.swing.border.Border;
|
||||||
import javax.swing.border.CompoundBorder;
|
import javax.swing.border.CompoundBorder;
|
||||||
@@ -139,8 +140,14 @@ public class FlatUIUtils
|
|||||||
return c instanceof JComponent && Boolean.TRUE.equals( ((JComponent)c).getClientProperty( "JComboBox.isTableCellEditor" ) );
|
return c instanceof JComponent && Boolean.TRUE.equals( ((JComponent)c).getClientProperty( "JComboBox.isTableCellEditor" ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns whether the given component is the permanent focus owner and
|
||||||
|
* is in the active window. Used to paint focus indicators.
|
||||||
|
*/
|
||||||
public static boolean isPermanentFocusOwner( Component c ) {
|
public static boolean isPermanentFocusOwner( Component c ) {
|
||||||
return (KeyboardFocusManager.getCurrentKeyboardFocusManager().getPermanentFocusOwner() == c);
|
KeyboardFocusManager keyboardFocusManager = KeyboardFocusManager.getCurrentKeyboardFocusManager();
|
||||||
|
return keyboardFocusManager.getPermanentFocusOwner() == c &&
|
||||||
|
keyboardFocusManager.getActiveWindow() == SwingUtilities.windowForComponent( c );
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isRoundRect( Component c ) {
|
public static boolean isRoundRect( Component c ) {
|
||||||
|
|||||||
Reference in New Issue
Block a user