Được rồi, gần đây tôi đã tìm hiểu về WindowBuilder (Eclipse IDE) hỗ trợ tạo các ứng dụng Swing nhanh hơn. Tôi đã thêm một JTabbedPane bằng cách sử dụng cơ sở kéo và thả. Làm cách nào để thêm các tab vào đó? Tôi đã xem qua các thuộc tính nhưng tôi không thể tìm thấy cách thêm tab bằng WindowBuilder. Mặc dù tôi đã thêm các tab theo cách thủ công nhưng tôi chỉ muốn biết theo cách khác là như thế nào.
28
2 trả lời
2
answer
86

10:08:23 13/02/2014
Chỉ cần thêm một JPanel
vào JTabbedPane
. Tab sẽ xuất hiện. Để thêm các tab khác, chỉ cần nhấp vào bên cạnh tiêu đề tab, JPanel
vẫn được chọn. Để chuyển đổi giữa các tab, chỉ cần nhấp đúp vào tiêu đề tab
86 hữu ích
5 bình luận
chia sẻ
answer
-1

15:40:37 08/12/2016
Ví dụ đơn giản về JTabbedPane
import java.awt.*;
import javax.swing.*;
public class JTabbedPaneDemo extends JFrame
{
JTabbedPane t1=new JTabbedPane();
JPanel p1,p2,p3;
Container c,c1;
JLabel l1,l2,l3;
JTextField text1,text2,text3;
JRadioButton r21,r22,r23;
JCheckBox ch1,ch2,ch3;
public JTabbedPaneDemo() {
setSize(500,300);
setVisible(true);
// TODO Auto-generated constructor stub
p1=new JPanel();
p2=new JPanel();
p3=new JPanel();
c1=getContentPane();
p1.setLayout(new GridLayout(3,2));
l1=new JLabel("Name");
l2=new JLabel("Date of Birth (dd.mm.yyyy)");
l3=new JLabel("Identification Number");
text1=new JTextField(10);
text2=new JTextField(10);
text3=new JTextField(10);
p1.add(l1);
p1.add(text1);
p1.add(l2);
p1.add(text2);
p1.add(l3);
p1.add(text3);
c1.add(p1);
ch1=new JCheckBox("Computers");
ch2=new JCheckBox("Electronics");
ch3=new JCheckBox("Marketing");
r21=new JRadioButton("Graduate");
r22=new JRadioButton("Post Graduate");
r23=new JRadioButton("Ph.D");
ButtonGroup bg=new ButtonGroup();
bg.add(r21);
bg.add(r22);
bg.add(r23);
p2.add(r21);
p2.add(r22);
p2.add(r23);
p3.add(ch1);
p3.add(ch2);
p3.add(ch3);
t1.addTab("Personal Information",p1);
t1.addTab("Education Qualification", p2);
t1.addTab("Area of intrest",p3);
add(t1);
}
public static void main(String[] args)
{
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
// TODO Auto-generated method stub
new JTabbedPaneDemo();
}
});
}
}
-1 hữu ích
0 bình luận
chia sẻ
Xem nguồn: https://stackoverflow.com/questions/21750314/how-to-add-tabs-to-jtabbedpane-using-windowbuilder

Không tìm thấy câu trả lời bạn tìm kiếm? Duyệt qua các câu hỏi được gắn thẻ
hỏi câu hỏi của bạn.
, hoặc Có thể bạn quan tâm

Hoạt động
Liên quan
Mới tạo