Display page for TabbedPane1 at www.BruceEckel.com
TabbedPane1.java
//: c14:TabbedPane1.java
// Demonstrates the Tabbed Pane.
// <applet code=TabbedPane1 width=350 height=200></applet>
import javax.swing.*;
import javax.swing.event.*;
import java.awt.*;
import com.bruceeckel.swing.*;
public class TabbedPane1 extends JApplet {
private String[] flavors = {
"Chocolate", "Strawberry", "Vanilla Fudge Swirl",
"Mint Chip", "Mocha Almond Fudge", "Rum Raisin",
"Praline Cream", "Mud Pie"
};
private JTabbedPane tabs = new JTabbedPane();
private JTextField txt = new JTextField(20);
public void init() {
for(int i = 0; i < flavors.length; i++)
tabs.addTab(flavors[i],
new JButton("Tabbed pane " + i));
tabs.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent e) {
txt.setText("Tab selected: " +
tabs.getSelectedIndex());
}
});
Container cp = getContentPane();
cp.add(BorderLayout.SOUTH, txt);
cp.add(tabs);
}
public static void main(String[] args) {
Console.run(new TabbedPane1(), 350, 200);
}
} ///:~
Wyszukiwarka
Podobne podstrony:
TabbedPane1Frame (2)BasicTabbedPaneUI TabbedPaneLayoutMetalTabbedPaneUI TabbedPaneLayout2008 01 Tabbed DialogMetalTabbedPaneUI TabbedPaneLayoutBasicTabbedPaneUI TabbedPaneLayoutTabbedPaneUITabbedPaneUIwięcej podobnych podstron