package com.mindprod.example;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import java.awt.Color;
import java.awt.Container;
import java.awt.FlowLayout;
import static java.lang.System.*;
/**
* demonstrate the use of javax.swing.JPanel.
*
* @author Roedy Green, Canadian Mind Products
* @version 1.0 2009-04-26 initial version
* @since 2009-04-26
*/
@SuppressWarnings( { "UnusedDeclaration" } )
final class TestJPanel
{
/**
* height of frame in pixels
*/
private static final int height = 100;
/**
* width of frame in pixels
*/
private static final int width = 300;
private static final String RELEASE_DATE = "2009-02-26";
/**
* title for frame
*/
private static final String TITLE_STRING = "JPanel Demo";
/**
* program version
*/
private static final String VERSION_STRING = "1.0";
/**
* Debugging harness for a JFrame
*
* @param args command line arguments are ignored.
*/
@SuppressWarnings( { "UnusedParameters" } )
public static void main( String args[] )
{
SwingUtilities.invokeLater( new Runnable()
{
/**
* } fire up a JFrame on the Swing thread
*/
public void run()
{
try
{
UIManager.setLookAndFeel( new com.sun.java.swing.plaf.motif.MotifLookAndFeel() );
}
catch ( Exception e )
{
err.println();
e.printStackTrace( err );
err.println( "Problem setting look and feel" );
err.println();
}
JFrame.setDefaultLookAndFeelDecorated( true );
final JFrame jframe = new JFrame( TITLE_STRING + " " + VERSION_STRING );
final Container contentPane = jframe.getContentPane();
jframe.setSize( width, height );
contentPane.setBackground( Color.YELLOW );
contentPane.setForeground( Color.BLUE );
final JPanel jPanel = new JPanel();
jPanel.setBackground( Color.ORANGE );
jPanel.setForeground( Color.GREEN );
jPanel.setLayout( new FlowLayout() );
jPanel.add( new JLabel( "Test" ) );
contentPane.add( jPanel );
jframe.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
jframe.validate();
jframe.setVisible( true );
}
} );
}
}