Posts

Showing posts from July, 2010

Java - Change Look And Feel of Swing applications

This java class LookAndFeelJMenu extends the swing component JMenu which can be added directly to a JMenuBar.
LookAndFeelJMenu will show a list of all LookAndFeels that are installed in your JRE.
Selecting a menu item from the menu will cause your swing application to switch to that LookAndFeel immediately.

package Livares; import javax.swing.JMenu; import javax.swing.JMenuItem; import javax.swing.SwingUtilities; import javax.swing.UIManager; /** * * @author Livares */ public class LookAndFeelJMenu extends JMenu { public LookAndFeelJMenu(String name,final java.awt.Component rootComponent){ super(name); final UIManager.LookAndFeelInfo looks[] = UIManager.getInstalledLookAndFeels(); for(int i=0;i<looks.length;i++){ final int index=i; JMenuItem theme = new JMenuItem(); theme.setText(looks[index].getName()); theme.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed…