FileDocCategorySizeDatePackage
MetalThemeMenu.javaAPI DocSun JDK 1.4.2 Example3019Thu May 12 00:35:27 BST 2005None

MetalThemeMenu

public class MetalThemeMenu extends JMenu implements ActionListener
This class describes a theme using "green" colors.
version
1.9 01/23/03
author
Steve Wilson

Fields Summary
MetalTheme[]
themes
Constructors Summary
public MetalThemeMenu(String name, MetalTheme[] themeArray)

    super(name);
    themes = themeArray;
    ButtonGroup group = new ButtonGroup();
    for (int i = 0; i < themes.length; i++) {
        JRadioButtonMenuItem item = new JRadioButtonMenuItem( themes[i].getName() );
	group.add(item);
        add( item );
	item.setActionCommand(i+"");
	item.addActionListener(this);
	if ( i == 0)
	    item.setSelected(true);
    }

  
Methods Summary
public voidactionPerformed(java.awt.event.ActionEvent e)

    String numStr = e.getActionCommand();
    MetalTheme selectedTheme = themes[ Integer.parseInt(numStr) ];
    MetalLookAndFeel.setCurrentTheme(selectedTheme);
    try {
	UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");
    } catch (Exception ex) {
        System.out.println("Failed loading Metal");
	System.out.println(ex);
    }