java将页面添加到选项卡中_在一个Java窗口中添加选项卡,添加不上,觉得是不是被覆盖了?怎么才能自己定义选项卡的位置?...

publicclassMainWindowextendsJFrame{publicMainWindow(){super("丹妮商场管理系统");Containerc=getContentPane();c.setLayout(null);//空布局管理器//顶端按钮,并通过for循环将按钮...

public class MainWindow extends JFrame{

public MainWindow() {

super("丹妮商场管理系统");

Container c= getContentPane();

c.setLayout(null);//空布局管理器

//顶端按钮,并通过for循环将按钮添加到容器中

JButton [] jb_top1= {new JButton("注销用户"),new JButton("退出系统"),new JButton("系统备份"),new JButton("帮助"),};

for(int i=0;i

jb_top1[i].setBounds( i*110, 0, 110, 20);

c.add(jb_top1[i]);

}

//第二层组件

JLabel top2_num = new JLabel("账号:");

JLabel top2_name = new JLabel("姓名:");

JLabel top2_time = new JLabel("时间:");

JButton n = new JButton("个人详情");

JTextField num_file = new JTextField();

JTextField name_file = new JTextField();

top2_num.setBounds(20, 30, 60, 20);

c.add(top2_num);

num_file.setBounds(80, 30, 80, 20);

c.add(num_file);

top2_name.setBounds(180, 30, 60, 20);

c.add(top2_name);

name_file.setBounds(240, 30, 80, 20);

c.add(name_file);

n.setBounds(350, 30, 110, 20);

c.add(n);

top2_time.setBounds(480, 30, 60, 20);

c.add(top2_time);

//选项卡窗格的实现

JTabbedPane tabbedPane = new JTabbedPane();//定义一个选项卡窗格并命名为tabbedPane并置于顶层

JPanel pa,pb,pc,pd; //定义窗格的四个面板

//实例化面板

pa = new JPanel(null);

pb = new JPanel(null);

pc = new JPanel(null);

pd = new JPanel(null);

//面板信息及顺序

tabbedPane.addTab("个人信息",null,pa,"First panel");

tabbedPane.addTab("信息完善",null,pb,"Second panel");

tabbedPane.addTab("信息查询",null,pc,"Third panel");

tabbedPane.addTab("信息",null,pd,"Four panel");

this.add(tabbedPane);

this.setSize(900, 700);

this.setVisible(true);

this.setResizable(false);//设置窗口大小不可变

this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

}

public static void main(String[] args) {

new MainWindow();

}

}

展开

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值