Please send questions to
st10@humboldt.edu .
/**
* TryJTabbedPane1
*
* a simple example of the JTabbedPane component
*
* RECOMMENDED SIZE: 500 x 500
*
* modified by: Sharon M. Tuttle
* last modified: 2-26-01
**/
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
// oops --- that's a 1 (One), not an l (lower-case el) at the end
// of this class name! JTabbedPane...
public class TryJTabbedPane1 extends JApplet
{
Container myContentPane;
JTabbedPane myTPane;
public void init()
{
JButton paneButton;
JPanel panePanel;
myContentPane = getContentPane();
// create a new instance of a JTabbedPane
myTPane = new JTabbedPane();
// one way to add a tabbed pane: use the addTab()
// method with a string name for the tab, followed
// by the component to appear on that tab.
// here we are, adding a JLabel on one tabbed pane
myTPane.addTab("JLabel Greeting", new JLabel("Bonjour"));
// now let's add a JButton on another tabbed pane
paneButton = new JButton("JButton on a Pane");
paneButton.setFont(new Font("serif", Font.BOLD, 26));
paneButton.setBackground(Color.green);
myTPane.addTab("JButton Demo", paneButton);
// can I add a JPanel on the tabbed pane?
panePanel = new JPanel();
panePanel.setBackground(Color.red);
panePanel.add(new JButton("dummy button"));
myTPane.addTab("JPanel Demo", panePanel);
// finally: don't forget to add the tabbed pane itself
// to the appropriate content pane...!
myContentPane.add(myTPane, "Center");
}
}