订购从零开始:-)
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
例如 :-)
import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;
public class TabbedPane {
private static final long serialVersionUID = 1L;
public TabbedPane() {
JPanel jp = new JPanel();
jp.setLayout(new BorderLayout());
final JTabbedPane tb = new JTabbedPane();
//tb.setUI(new CustomTabbedPaneUI());
JButton btn = new JButton("push me !!!");
btn.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
tb.setEnabledAt(1, true);
tb.setEnabledAt(2, true);
tb.setEnabledAt(3, true);
tb.setEnabledAt(4, true);
}
});
JPanel pnl = new JPanel();
pnl.add(btn);
tb.add("Tab1", pnl);
tb.add("Tab2", new JTextArea(10, 20));
tb.add("Tab3", new JTextArea(10, 20));
tb.add("Tab4", new JTextArea(10, 20));
tb.add("Tab5", new JTextArea(10, 20));
jp.add(tb, BorderLayout.CENTER);
//add(jp, BorderLayout.CENTER);
tb.setEnabledAt(1, false);
tb.setEnabledAt(2, false);
tb.setEnabledAt(3, false);
tb.setEnabledAt(4, false);
JFrame frame = new JFrame();
frame.setLayout(new BorderLayout());
frame.add(jp, BorderLayout.CENTER);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.pack();
frame.setVisible(true);
}
public static void main(String[] args) {
try {
for (UIManager.LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (Exception system) {
system.printStackTrace();
}
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
TabbedPane tP = new TabbedPane();
}
});
}
}