Skip to content

Instantly share code, notes, and snippets.

@Vaysman
Created February 21, 2017 10:36
Show Gist options
  • Save Vaysman/8cd76023cabd7b60bc69b6f8d9f25d5a to your computer and use it in GitHub Desktop.
Save Vaysman/8cd76023cabd7b60bc69b6f8d9f25d5a to your computer and use it in GitHub Desktop.
import javax.swing.*;
import java.awt.*;
public class Form01 extends JFrame {
private final static Color SKYDARK =new Color(128,200,255);
private Form01() {
initComponents();
}
private void initComponents() {
JPanel panel = new JPanel();
setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
final JMenuBar jMenuBar = new JMenuBar();
ButtonGroup themeButtonGroup = new ButtonGroup();
jMenuBar.setBackground(new Color(204, 255, 204));
JMenu themeMenu = new JMenu("Оформление");
JRadioButtonMenuItem themeSelector = new JRadioButtonMenuItem("Sky", true);
themeButtonGroup.add(themeSelector);
themeSelector.addActionListener((evt) -> jMenuBar.setBackground(SKYDARK));
themeMenu.add(themeSelector);
themeSelector = new JRadioButtonMenuItem("Ignis", false);
themeButtonGroup.add(themeSelector);
themeSelector.addActionListener((evt) -> jMenuBar.setBackground(Color.BLACK));
themeMenu.add(themeSelector);
JMenu settingsMenu = new JMenu("Настройки");
settingsMenu.add(themeMenu);
jMenuBar.add(settingsMenu);
setJMenuBar(jMenuBar);
panel.setPreferredSize(new Dimension(300, 300));
getContentPane().add(panel);
pack();
}
public static void main(String args[]) {
try {
for (UIManager.LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
if ("Windows".equals(info.getName())) {
UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (Exception ex) {
java.util.logging.Logger.getLogger(Form01.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
EventQueue.invokeLater(() -> new Form01().setVisible(true));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment