Java Code



import java.awt.*;
import javax.swing.*; 
public class JTabEx extends JApplet
{
  JButton b_China, b_Germany;
  JLabel flowers;
  Image img1, img2, img3;
  ImageIcon iconWindow, iconStatue, iconFlowers;
  JPanel panel;
  JTabbedPane tabpane;
  public void init( ) 
  { 
    tabpane = new JTabbedPane( );
    img1 = getImage(getCodeBase( ), "Window.jpg" );
    img2 = getImage(getCodeBase( ), "Statue.jpg" );
    img3 = getImage(getCodeBase( ), "Flowers.jpg" );
    iconWindow = new ImageIcon(img1);
    iconStatue = new ImageIcon(img2);
    iconFlowers = new ImageIcon(img3);   
    b_China = new JButton( "", iconWindow );
    b_Germany = new JButton( "What an idea!", iconStatue );
    flowers = new JLabel( iconFlowers );
    panel = new JPanel( );
    panel.add(b_China);

	// add tabs
    tabpane.addTab( "China", panel );
    tabpane.addTab( "Germany", b_Germany );
    tabpane.addTab( "Slovakia", iconFlowers, flowers, "Slovakia" );

	// add tabbed pane to applet
	add( tabpane, BorderLayout.CENTER );
   }
} 

Return to Code Examples
©2007 E.S.Boese