ComboBox: paint focus border if combobox component itself is focused (instead of internal text field) or if client property JComponent.focusOwner is set

Theme Editor:
- do not set client property `JComponent.focusOwner` on internal components of combobox and spinner
- repaint preview on window activation (necessary because if something changed in editor and switching to another app, the editor is saved and the preview is updated while the editor window is not-active, which hides all focus indicators)
This commit is contained in:
Karl Tauber
2021-09-28 19:34:53 +02:00
parent 06b3de720a
commit 82df2ecfa9
4 changed files with 21 additions and 2 deletions

View File

@@ -166,6 +166,11 @@ class FlatThemeEditorPane
scrollPane.getGutter().setLineNumberFont( font );
}
void windowActivated() {
if( preview != null )
preview.repaint();
}
@Override
public boolean requestFocusInWindow() {
return textArea.requestFocusInWindow();

View File

@@ -148,6 +148,14 @@ class FlatThemeFileEditor
restoreState();
restoreWindowBounds();
addWindowListener( new WindowAdapter() {
@Override
public void windowActivated( WindowEvent e ) {
for( FlatThemeEditorPane themeEditorPane : getThemeEditorPanes() )
themeEditorPane.windowActivated();
}
} );
// load directory
if( dir == null ) {
String recentDirectory = state.get( KEY_RECENT_DIRECTORY, null );

View File

@@ -188,8 +188,11 @@ class FlatThemePreviewAll
if( !isControlComponent( comp ) && comp instanceof JComponent )
((JComponent)comp).putClientProperty( FlatClientProperties.COMPONENT_FOCUS_OWNER, value );
if( !(comp instanceof Container) || comp instanceof JInternalFrame )
return;
if( !(comp instanceof Container) ||
comp instanceof JComboBox ||
comp instanceof JSpinner ||
comp instanceof JInternalFrame )
return;
for( Component c : ((Container)comp).getComponents() ) {
if( c instanceof JScrollPane )