// 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 metal = new JButton("Metal");
   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(6, 1));
      windows.addActionListener(this);
      getContentPane().add(windows);
      motif.addActionListener(this);
      getContentPane().add(motif);
      metal.addActionListener(this);
      getContentPane().add(metal);
      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() == metal) {
            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.show();
   }
}
