Theme Editor: fixed preview when switching Laf

This commit is contained in:
Karl Tauber
2021-08-22 00:39:49 +02:00
parent 31cadc532b
commit ae4c69e75c
2 changed files with 9 additions and 2 deletions

View File

@@ -154,6 +154,9 @@ class FlatThemeEditorPane
// error strip
errorStrip.setCaretMarkerColor( UIManager.getColor( "FlatThemeEditorPane.errorstrip.caretMarkerColor" ) );
if( preview != null )
preview.updateLater();
}
void updateFontSize( int sizeIncr ) {
@@ -271,7 +274,7 @@ class FlatThemeEditorPane
preview = new FlatThemePreview( textArea );
previewScrollPane = new JScrollPane( preview );
previewScrollPane.setHorizontalScrollBarPolicy( JScrollPane.HORIZONTAL_SCROLLBAR_NEVER );
previewScrollPane.setBorder( null );
previewScrollPane.setBorder( BorderFactory.createEmptyBorder() );
previewScrollPane.getVerticalScrollBar().setUnitIncrement( 20 );
previewScrollPane.getHorizontalScrollBar().setUnitIncrement( 20 );
add( previewScrollPane, BorderLayout.LINE_END );

View File

@@ -67,7 +67,7 @@ class FlatThemePreview
// update when showing preview (e.g. activating tab)
addHierarchyListener( e -> {
if( (e.getChangeFlags() & HierarchyEvent.SHOWING_CHANGED) != 0 && isShowing() )
EventQueue.invokeLater( this::update );
updateLater();
} );
}
@@ -85,6 +85,10 @@ class FlatThemePreview
public void changedUpdate( DocumentEvent e ) {
}
void updateLater() {
EventQueue.invokeLater( this::update );
}
private void update() {
if( !isShowing() )
return;