如何使用WindowBuilder添加标签到JTabbedPane ?

时间:2022-09-11 18:43:38

Ok so I've recently found out about WindowBuilder (Eclipse IDE) that aids in faster creation of Swing applications. I have a added a JTabbedPane using the drag and drop facility. How can I add tabs to it? I have gone through the properties but I couldn't find how to add tabs using WindowBuilder. Although I have manually added tabs but I just want to know what is the other way round.

好的,我最近发现了关于windows builder (Eclipse IDE),它有助于更快地创建Swing应用程序。我使用拖放工具添加了一个JTabbedPane。如何添加标签?我已经浏览了这些属性,但是我找不到如何使用WindowBuilder添加标签。虽然我已经手动添加了标签,但我只是想知道另一种方法是什么。

3 个解决方案

#1


75  

Just add a JPanel to the JTabbedPane. The tab will appear. To add more tabs just click the next to the tab header, with the JPanel still selected. To switch between tabs just double click the tab header

只需在JTabbedPane中添加一个JPanel。标签就会出现。要添加更多的选项卡,只需单击选项卡头的旁边,JPanel仍然被选中。要在选项卡之间切换,只需双击标签页眉。

如何使用WindowBuilder添加标签到JTabbedPane ?

#2


0  

For Netbeans just follow the following awesome link: http://my.safaribooksonline.com/book/programming/java/9780137017256/gui-builder/ch06lev1sec3

对于Netbeans,请遵循以下链接:http://my.safaribooksonline.com/book/programming/java/9780137017256/gui-builder/ch06lev1sec3。

#3


0  

Simple example of JTabbedPane

简单的例子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


75  

Just add a JPanel to the JTabbedPane. The tab will appear. To add more tabs just click the next to the tab header, with the JPanel still selected. To switch between tabs just double click the tab header

只需在JTabbedPane中添加一个JPanel。标签就会出现。要添加更多的选项卡,只需单击选项卡头的旁边,JPanel仍然被选中。要在选项卡之间切换,只需双击标签页眉。

如何使用WindowBuilder添加标签到JTabbedPane ?

#2


0  

For Netbeans just follow the following awesome link: http://my.safaribooksonline.com/book/programming/java/9780137017256/gui-builder/ch06lev1sec3

对于Netbeans,请遵循以下链接:http://my.safaribooksonline.com/book/programming/java/9780137017256/gui-builder/ch06lev1sec3。

#3


0  

Simple example of JTabbedPane

简单的例子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();

        }
    });
}

}

}