Skip to content

Commit

Permalink
Demo: Add option to select all available installed Lafs.
Browse files Browse the repository at this point in the history
  • Loading branch information
weisJ committed Apr 10, 2021
1 parent 3b5d390 commit 9fc4dc1
Showing 1 changed file with 22 additions and 11 deletions.
33 changes: 22 additions & 11 deletions core/src/test/java/ui/ComponentDemo.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import com.github.weisj.darklaf.theme.event.ThemeInstalledListener;
import com.github.weisj.darklaf.theme.info.PreferredThemeStyle;
import com.github.weisj.darklaf.ui.rootpane.DarkRootPaneUI;
import com.github.weisj.darklaf.util.Lambdas;
import com.github.weisj.darklaf.util.PropertyUtil;

public interface ComponentDemo {
Expand Down Expand Up @@ -242,18 +243,28 @@ default JMenu createDevSettings() {
.putClientProperty(DarkRootPaneUI.KEY_UNIFIED_MENUBAR, isSelected()));
}
});
dev.add(new JCheckBoxMenuItem("Darklaf/System Laf") {
{
setSelected(LafManager.isInstalled());
addActionListener(e -> {
if (isSelected()) {
LafManager.install();
} else {
installSystemLaf();
}
});
JMenu lafs = new JMenu("Laf");
ButtonGroup lafBg = new ButtonGroup();
JMenuItem darklafLaf = new JRadioButtonMenuItem("Darklaf");
lafBg.add(darklafLaf);
lafs.add(darklafLaf);
darklafLaf.setSelected(true);
darklafLaf.addActionListener(e -> LafManager.install());
for (UIManager.LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
if (info.getName().startsWith("com.github.weisj.darklaf")) continue;
JMenuItem item = new JRadioButtonMenuItem(info.getName());
lafBg.add(item);
lafs.add(item);
if (UIManager.getLookAndFeel().getClass().getName().equals(info.getClassName())) {
item.setSelected(true);
}
});
Runnable lafSetter = Lambdas.wrap(() -> {
UIManager.setLookAndFeel(info.getClassName());
LafManager.updateLaf();
});
item.addActionListener(e -> lafSetter.run());
}
dev.add(lafs);
return dev;
}

Expand Down

0 comments on commit 9fc4dc1

Please sign in to comment.