import java.util.HashMap;\r
import java.util.Map;\r
\r
+import javax.swing.ButtonGroup;\r
import javax.swing.JCheckBoxMenuItem;\r
import javax.swing.JFrame;\r
import javax.swing.JLabel;\r
import javax.swing.JSeparator;\r
import javax.swing.JTabbedPane;\r
import javax.swing.JTextArea;\r
+import javax.swing.LookAndFeel;\r
import javax.swing.SwingUtilities;\r
import javax.swing.UIManager;\r
import javax.swing.WindowConstants;\r
}\r
\r
private void initComponents(){\r
+ setDefaultUI();\r
JMenuBar menubar = new JMenuBar();\r
menubar.add(createFileMenu());\r
menubar.add(createHelpMenu());\r
JMenuItem about = Utility.createJMenuItem("about", new AboutAction(this));\r
JMenuItem license = Utility.createJMenuItem("license", new LicenseAction(this));\r
JMenuItem help = Utility.createJMenuItem("helpmenu");\r
- JMenu laf = Utility.createJMenu("lookandfeel");\r
expertmodeMenu = Utility.createJCheckBoxMenuItem("expertmenu");\r
\r
menu.add(about);\r
menu.add(license);\r
menu.add(help);\r
menu.add(new JSeparator());\r
- menu.add(laf);\r
+ menu.add(createLookAndFeelMenu());\r
menu.add(new JSeparator());\r
menu.add(expertmodeMenu);\r
\r
expertMenuActionPerformed(((JCheckBoxMenuItem)e.getSource()).getState());\r
}\r
});\r
+ help.setEnabled(false);\r
+\r
+ return menu;\r
+ }\r
\r
- final UIManager.LookAndFeelInfo[] info = UIManager.getInstalledLookAndFeels();\r
+ private JMenu createLookAndFeelMenu(){\r
+ JMenu laf = Utility.createJMenu("lookandfeel");\r
+ ButtonGroup bg = new ButtonGroup();\r
+ UIManager.LookAndFeelInfo[] info = UIManager.getInstalledLookAndFeels();\r
+ LookAndFeel lookfeel = UIManager.getLookAndFeel();\r
+\r
+ ActionListener listener = new ActionListener(){\r
+ public void actionPerformed(ActionEvent e){\r
+ try{\r
+ String command = e.getActionCommand();\r
+ UIManager.setLookAndFeel(command);\r
+ SwingUtilities.updateComponentTreeUI(StigmataFrame.this);\r
+ } catch(Exception ee){\r
+ }\r
+ }\r
+ };\r
for(int i = 0; i < info.length; i++){\r
- final int index = i;\r
- JMenuItem item = new JMenuItem(info[i].getName());\r
+ JCheckBoxMenuItem item = new JCheckBoxMenuItem(info[i].getName());\r
+ item.setActionCommand(info[i].getClassName());\r
+ item.addActionListener(listener);\r
+ bg.add(item);\r
laf.add(item);\r
- item.addActionListener(new ActionListener(){\r
- public void actionPerformed(ActionEvent e){\r
- try{\r
- UIManager.setLookAndFeel(info[index].getClassName());\r
- SwingUtilities.updateComponentTreeUI(StigmataFrame.this);\r
- }catch(Exception ee){\r
- }\r
- }\r
- });\r
+\r
+ if(info[i].getClassName().equals(lookfeel.getClass().getName())){\r
+ item.setState(true);\r
+ }\r
}\r
- help.setEnabled(false);\r
\r
- return menu;\r
+ return laf;\r
}\r
\r
public void setExpertMode(boolean expertmode){\r
countmap.put(label, i);\r
return i;\r
}\r
+\r
+ private void setDefaultUI(){\r
+ try{\r
+ UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());\r
+ } catch(Exception e){\r
+ }\r
+ }\r
}\r