如何在java swing中创建制表符

时间:2015-11-02 14:24:07

标签: java swing

您好如何将此值放在标签

我得到4个值的标签创建用户更新,删除,搜索

topPanel.setLayout(null);
nameLabel.setBounds(300, 30, 150, 20);
txtName.setBounds(350,30,150,20);
surnameLabel.setBounds(300, 65, 150, 20);
txtSurname.setBounds(350,65,150,20);
passwordLabel.setBounds(70, 220, 150, 20);
passwordField.setBounds(130, 160, 150, 20);  

topPanel.add(nameLabel);
topPanel.add(txtName);
topPanel.add(surnameLabel);
topPanel.add(txtSurname);
topPanel.add(passwordLabel);
topPanel.add(passwordField);

2 个答案:

答案 0 :(得分:3)

创建JTabbedPane

JTabbedPane tabbedPane = new JTabbedPane();

并在该窗格中添加标签。

tabbedPane.addTab("Tab 1", icon, panel1,
                   "Does nothing");
@LuxxMiner提供的

link非常好。

答案 1 :(得分:2)

  

你可以这样做:

JTabbedPane tabbePane = new JTabbedPane();
JPanel  panel1 = new JPanel();
JPanel panel2 = new JPanel();
JTextField  field = new JTextField();
JButton  button = new JButton();


tabbedPane.addTab("tab1", panel1);

field.setText("Your text here");
panel2.add(field);

button.setText("Save");
panel2.add(button);

tabbePane.addTab("tab2", panel2);