/*
 * Demonstration of Swing - showing how selecting different looks and feels
 * before creating a GUI component results in creating a components with
 * different visual appearances.  A button is used for illustration because
 * each look and feel uses a distinctive physical appearance for a button
 *
 * Copyright (c) 2001 - Russell C. Bjork
 *
 */
 
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

class SwingDemo extends JFrame
{
	/** Main program - construct an illustrative frame, then show it.
	 */
	public static void main(String [] args)  throws Exception
	{
		SwingDemo swing = new SwingDemo();
		swing.setVisible(true);
	}

	/** Constructor - create a frame containing several buttons, each with a
	 *  different look and feel.  The name of the button will indicate what
	 *  look and feel it exemplifies.
	 */
	public SwingDemo() throws Exception
	{
		getContentPane().setLayout(new GridLayout(0, 1));
		
		// Each time through this loop, we specify a different look and feel
		
		for (int i = 0; i < 4; i ++)
		{
			String buttonName = "";
			
			try
			{
				switch(i)
				{
					case 0: 
					
						UIManager.setLookAndFeel(
							"apple.laf.AquaLookAndFeel");
						buttonName = "This is in the Macintosh look and feel";
						break;
						
					case 1:
					
						UIManager.setLookAndFeel(
							"com.sun.java.swing.plaf.motif.MotifLookAndFeel");
						buttonName = "This is in the Motif look and feel";
						break;
						
					case 2:
						
						UIManager.setLookAndFeel(
							"javax.swing.plaf.metal.MetalLookAndFeel");
						buttonName = "This is in the Metal look and feel";
						break;
						
					case 3:
					
						UIManager.setLookAndFeel(
							"com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
						buttonName = "This is in the Windows look and feel";
						break;
						
				}

				// Create and add a new button with the current look and feel.
				// The button's name will indicate which look and feel it exemplifies
				
				getContentPane().add(new JButton(buttonName));
			}
			catch(Exception e)
			{
				System.out.println("Exception " + e);
			}
		}
		
		pack();
	}
}
	
