Menus: support switching "underline" menu selection type at any time without updating UI (issue #49)

This commit is contained in:
Karl Tauber
2020-04-29 14:46:33 +02:00
parent 395333cb3d
commit 875637bc6d
3 changed files with 4 additions and 4 deletions

View File

@@ -55,7 +55,6 @@ public class FlatMenuItemRenderer
protected final int textAcceleratorGap; protected final int textAcceleratorGap;
protected final int textArrowGap; protected final int textArrowGap;
protected final String selectionType = UIManager.getString( "MenuItem.selectionType" );
protected final Color underlineSelectionBackground = UIManager.getColor( "MenuItem.underlineSelectionBackground" ); protected final Color underlineSelectionBackground = UIManager.getColor( "MenuItem.underlineSelectionBackground" );
protected final Color underlineSelectionColor = UIManager.getColor( "MenuItem.underlineSelectionColor" ); protected final Color underlineSelectionColor = UIManager.getColor( "MenuItem.underlineSelectionColor" );
protected final int underlineSelectionHeight = UIManager.getInt( "MenuItem.underlineSelectionHeight" ); protected final int underlineSelectionHeight = UIManager.getInt( "MenuItem.underlineSelectionHeight" );
@@ -340,7 +339,7 @@ debug*/
} }
private boolean isUnderlineSelection() { private boolean isUnderlineSelection() {
return "underline".equals( selectionType ); return "underline".equals( UIManager.getString( "MenuItem.selectionType" ) );
} }
private Icon getIconForPainting() { private Icon getIconForPainting() {

View File

@@ -61,7 +61,6 @@ class DemoFrame
private void underlineMenuSelection() { private void underlineMenuSelection() {
UIManager.put( "MenuItem.selectionType", underlineMenuSelectionMenuItem.isSelected() ? "underline" : null ); UIManager.put( "MenuItem.selectionType", underlineMenuSelectionMenuItem.isSelected() ? "underline" : null );
FlatLaf.updateUI();
} }
private void fontFamilyChanged( ActionEvent e ) { private void fontFamilyChanged( ActionEvent e ) {

View File

@@ -64,7 +64,9 @@ public class FlatMenusTest
private void underlineChanged() { private void underlineChanged() {
UIManager.put( "MenuItem.selectionType", underlineCheckBox.isSelected() ? "underline" : null ); UIManager.put( "MenuItem.selectionType", underlineCheckBox.isSelected() ? "underline" : null );
FlatLaf.updateUI();
if( armedCheckBox.isSelected() )
FlatLaf.updateUI();
} }
private void showPopupMenuButtonActionPerformed(ActionEvent e) { private void showPopupMenuButtonActionPerformed(ActionEvent e) {