How to add tabs to JTabbedPane using WindowBuilder

0 votes
I have  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.
Apr 21, 2020 in Java by kartik
• 37,520 points
1,154 views

1 answer to this question.

0 votes

Hii,

You can just find out by given example

Example of 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();

        }
    });
}

}

answered Apr 21, 2020 by Niroj
• 82,840 points

Related Questions In Java

0 votes
3 answers

How to read input from Console using Scanner Class?

A simple example: import java.util.Scanner; public class Expl { ...READ MORE

answered Aug 1, 2018 in Java by samarth295
• 2,220 points
5,190 views
0 votes
3 answers

How can I add new elements to an Array in Java

String[] source = new String[] { "a", ...READ MORE

answered Sep 19, 2018 in Java by Sushmita
• 6,920 points
13,212 views
0 votes
2 answers

How to read the files using Java?

You can use collections. try (Stream<Path> filePathStream=Files.walk(Paths.get("/home/you/Desktop"))) { ...READ MORE

answered Jul 10, 2018 in Java by Sushmita
• 6,920 points
1,124 views
0 votes
2 answers

How to get input from user using System.console()?

Scanner in = new Scanner(System.in); int i = ...READ MORE

answered Aug 2, 2018 in Java by Sushmita
• 6,920 points
1,101 views
0 votes
1 answer

What are the prerequisites to learn Hadoop in java perspective?

In my day job, I've just spent ...READ MORE

answered Oct 11, 2018 in Big Data Hadoop by Frankie
• 9,830 points
785 views
0 votes
1 answer

How is inheritance in C++ different than that in Java?

The purpose of inheritance is same for ...READ MORE

answered Feb 6, 2019 in Java by Priyaj
• 58,020 points
984 views
0 votes
1 answer

What is the reason for no ConcurrentHashSet against ConcurrentHashMap?

Hello, There's no built in type for ConcurrentHashSet because you ...READ MORE

answered Apr 8, 2020 in Java by Niroj
• 82,840 points
1,484 views
0 votes
1 answer

How to pass an object from one activity to another on Android?

Hello @kartik, Implement your class with Serializable. Let's ...READ MORE

answered Apr 8, 2020 in Java by Niroj
• 82,840 points
773 views
0 votes
1 answer

How to implement draggable tab using Java Swing?

Hello kartik, setAcceptor(TabAcceptor a_acceptor) should let the consumer code ...READ MORE

answered Apr 21, 2020 in Java by Niroj
• 82,840 points
1,287 views
0 votes
1 answer

How to add action listener that listens to multiple buttons?

Hii, modified form of the source based on ...READ MORE

answered Apr 21, 2020 in Java by Niroj
• 82,840 points
8,572 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP