62,614
社区成员
发帖
与我相关
我的任务
分享
import javax.swing.*;
public class JTabbedTest extends JFrame {
JTabbedPane tp = new JTabbedPane(JTabbedPane.TOP);
JPanel p1 = new JPanel();
JTextArea ta1 = new JTextArea();
JTextArea ta2 = new JTextArea();
public JTabbedTest(){
ta1.append("show me the money");
ta2.append("show me the money");
tp.add("Tab1", ta1);
tp.add("Tab2", ta2);
p1.add(tp);
getContentPane().add(p1);
}
public static void main(String[] args) {
JTabbedTest a = new JTabbedTest();
a.setSize(300, 300);
a.setVisible(true);
}
}
JTextArea ta1 = new JTextArea();
JTextArea ta2 = new JTextArea();
JTabbedPane tp = new JTabbedPane();
ta1.append("show me the money");
ta1.append("please show me why");
ta2.append("showme why");
tp.insertTab("标签一",null,ta1,"标签一",0);
tp.insertTab("标签二",null,ta2,"标签二",1);
add(tp);
setLayout(new FlowLayout());
setVisible(true);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100,100,400,300);