import java.awt.*; import java.awt.event.*; import javax.swing.*; import javax.swing.border.*;//Fancy Borders public class FrameTest { JFrame frame; JLabel nLabel; JLabel sLabel; JLabel eLabel; JLabel cLabel; Conainer content; Container content2; Font f; Color c; Color current; public FrameTest( ){ nLabel = new JLabel( "I am the North Label", SwingConstants.Center ); sLabel = new JLabel( "I am the South Label", SwingConstants.Center ); eLabel = new JLabel( "I am the East Label", SwingConstants.Center ); wLabel = new JLabel( "I am the West Label", SwingConstants.Center ); cLabel = new JLabel( "I am the Center Label", SwingConstants.Center ); frame = new JFrame( "This is a test" ); frame.setBounds( 30, 30, 530, 530 );//sets size of frame. frame.setDefaultCloseOperation( WindowConstants.DISPOSE_ON_CLOSE ); f = new Font( "Comic Sans MS", Font.Bold, 14 ); content = frame.getContentPane( ); //returns content pane. current = content.getBackground( ); //tells me what the color is. content2 = new Container( ); c = new Color( 100, 50, 200 );//red, green, blue. content.add( nLabel, Borderlayout.NORTH ); content.add( nsLabel, Borderlayout.SOUTH ); content.add( eLabel, Borderlayout.EAST ); content.add( wLabel, Borderlayout.WEST ); content.add( cLabel, Borderlayout.CENTER ); //frame.pack( ); frame.setVisible( true ); } public void changeNorthLabel( String label )( nLabel.setFont( f ); nLabel.setText( label ); } public void changeNorthLabelBorder( ){ nLabel.setBorder( new BevelBorder( BevelBorder.LOWERED )); } public void changeBackgroundColor( int color ){ if( color > 0 && color < 7 ){ switch( color ){ case 1: content.setBackground( Color.red ); break; case 2: content.setBackground( Color.blue ); break; case 3: content.setBackground( Color.magenta ); break; case 4: content.setBackground( Color.cyan ); break; case 5: content.setBackground( c ); break; case 6: content.setBackground( current ); break; } } } public void changeContent( ){ content2.setLayout( new GridLayout( 2, 3 )); JLabel label1, label2, label3, label4, label5, label6; label1 = new JLabel( ); label1.setForground( Color.red ); label1.setText( "I am label 1" ); label1.setBorder( BorderFactory.createLineBorder( Color.red )); content2.add(label1 ); label2 = new JLabel( ); label2.setForground( Color.blue ); label2.setText( "I am label 2" ); label2.setBorder( BorderFactory.createLineBorder( Color.blue )); content2.add(label2 ); label3 = new JLabel( ); label3.setForground( Color.green ); label3.setText( "I am label 3" ); label3.setBorder( BorderFactory.createLineBorder( Color.green )); content2.add(label3 ); label4 = new JLabel( ); label4.setForground( Color.magenta); label4.setText( "I am label 4" ); label4.setBorder( BorderFactory.createLineBorder( Color.magenta )); content2.add(label4 ); label5 = new JLabel( ); label5.setForground( Color.cyan ); label5.setText( "I am label 5" ); label5.setBorder( BorderFactory.createLineBorder( Color.cyan )); content2.add(label5 ); label6 = new JLabel( ); label6.setForground( Color.orange ); label6.setText( "I am label 1" ); label6.setBorder( BorderFactory.createLineBorder( Color.orange )); content2.add(label6 ); frame.setContentPane( content2 ); frame.setVisible( true ); } public static void main( String [] args ){ FrameTest test = new FrameTest( ); } }