Skip to content

Commit

Permalink
Fix persistent JCheckboxMenuItemUI (#48)
Browse files Browse the repository at this point in the history
GH-2 Fixes PersistentJCheckboxMenuItem UI in case SynthUI is not available
  • Loading branch information
gtache committed Feb 27, 2020
1 parent c944369 commit 3304474
Showing 1 changed file with 16 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.icepdf.ri.common;

import javax.swing.*;
import javax.swing.plaf.basic.BasicCheckBoxMenuItemUI;
import javax.swing.plaf.synth.SynthCheckBoxMenuItemUI;

/**
Expand All @@ -19,11 +20,20 @@ public PersistentJCheckBoxMenuItem(String title, boolean b) {
@Override
public void updateUI() {
super.updateUI();
setUI(new SynthCheckBoxMenuItemUI() {
@Override
protected void doClick(MenuSelectionManager msm) {
menuItem.doClick(0);
}
});
if (getUI() instanceof SynthCheckBoxMenuItemUI) {
setUI(new SynthCheckBoxMenuItemUI() {
@Override
protected void doClick(MenuSelectionManager msm) {
menuItem.doClick(0);
}
});
} else {
setUI(new BasicCheckBoxMenuItemUI() {
@Override
protected void doClick(MenuSelectionManager msm) {
menuItem.doClick(0);
}
});
}
}
}

0 comments on commit 3304474

Please sign in to comment.