// Collection of code snippets by Arne Vajhøj 
// (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
import java.awt.*;
import java.awt.event.*;

import javax.swing.*;

public class MultiLookAndFeel extends JFrame implements ActionListener {
  private JButton windows = new JButton("Windows");
  private JButton motif = new JButton("Motif");
  private JButton metal1 = new JButton("Metal/ocean");
  private JButton metal2 = new JButton("Metal/steel");
  private JButton gtk = new JButton("GTK");
  private JButton java = new JButton("Java");
  private JButton system = new JButton("System");
  public MultiLookAndFeel() {
      setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      getContentPane().setLayout(new GridLayout(7, 1));
      windows.addActionListener(this);
      getContentPane().add(windows);
      motif.addActionListener(this);
      getContentPane().add(motif);
      metal1.addActionListener(this);
      getContentPane().add(metal1);
      metal2.addActionListener(this);
      getContentPane().add(metal2);
      gtk.addActionListener(this);
      getContentPane().add(gtk);
      java.addActionListener(this);
      getContentPane().add(java);
      system.addActionListener(this);
      getContentPane().add(system);
      pack();
  }
  public void actionPerformed(ActionEvent e) {
      try {
        if(e.getSource() == windows) {
            UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
        } else if(e.getSource() == motif) {
            UIManager.setLookAndFeel("com.sun.java.swing.plaf.motif.MotifLookAndFeel");
        } else if(e.getSource() == metal1) {
            javax.swing.plaf.metal.MetalLookAndFeel.setCurrentTheme(new javax.swing.plaf.metal.OceanTheme());
            UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");
        } else if(e.getSource() == metal2) {
            javax.swing.plaf.metal.MetalLookAndFeel.setCurrentTheme(new javax.swing.plaf.metal.DefaultMetalTheme());
            UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");
        } else if(e.getSource() == gtk) {
            UIManager.setLookAndFeel("com.sun.java.swing.plaf.gtk.GTKLookAndFeel");
        } else if(e.getSource() == java) {
            UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
        } else if(e.getSource() == system) {
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        }
      } catch (ClassNotFoundException e1) {
        e1.printStackTrace();
      } catch (InstantiationException e1) {
        e1.printStackTrace();
      } catch (IllegalAccessException e1) {
        e1.printStackTrace();
      } catch (UnsupportedLookAndFeelException e1) {
        e1.printStackTrace();
      }
      SwingUtilities.updateComponentTreeUI(this);
      pack();
  }
  public static void main(String[] args) {
      MultiLookAndFeel f = new MultiLookAndFeel();
      f.setVisible(true);
  }
}
