LookAndFeelTest.java



/** Look and Feel のテスト */
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.plaf.*;
import com.sun.java.swing.plaf.motif.*;
public class LookAndFeelTest extends JFrame {
 
  /** コンストラクタ */
    public LookAndFeelTest( LookAndFeel laf ) throws Exception {
        super();
        if( laf != null )
            setTitle( laf.getName() );
        else 
            setTitle( "Default Look and Feel" );
        try {
            if( laf != null )
                UIManager.setLookAndFeel( laf );
        }
        catch( Exception e ){
            throw e;
        }
        JPanel panel = new JPanel();
        JButton button = new JButton( "Button" );
        panel.add( button );
        JCheckBox check = new JCheckBox( "CheckBox", false );
        panel.add( check );
        JSlider slider = new JSlider();
        panel.add( slider );
        getContentPane().add( panel );
        pack();
        setVisible( true );
    }
 
  /** 起動時に呼び出されるメソッド */
    public static void main( String argv[] ) {
        try {
            LookAndFeelTest frame1 = new LookAndFeelTest( null );
            LookAndFeelTest frame2
                 = new LookAndFeelTest( new MotifLookAndFeel() );
        }
        catch( Exception e ){
            System.err.println( "Error:" + e.toString() );
        }
    }
}