org.icepdf.ri.common.PersistentJCheckBoxMenuItem Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of icepdf-viewer Show documentation
Show all versions of icepdf-viewer Show documentation
ICEpdf Java Swing/AWT reference implementation.
The newest version!
package org.icepdf.ri.common;
import javax.swing.*;
import javax.swing.plaf.basic.BasicCheckBoxMenuItemUI;
import javax.swing.plaf.synth.SynthCheckBoxMenuItemUI;
/**
* JCheckboxMenuItem that doesn't hide the menu when clicked
*/
public class PersistentJCheckBoxMenuItem extends JCheckBoxMenuItem {
public PersistentJCheckBoxMenuItem(String title) {
super(title);
}
public PersistentJCheckBoxMenuItem(String title, boolean b) {
super(title, b);
}
@Override
public void updateUI() {
super.updateUI();
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);
}
});
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy