Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8336671
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T04:04:05+00:00 2026-06-09T04:04:05+00:00

CTabItem tabItem1 = new CTabItem(newTabFolder, SWT.CLOSE); tabItem1.setText(Tab 1); Label lab2 = new Label(newTabFolder, 0);

  • 0
CTabItem tabItem1 = new CTabItem(newTabFolder, SWT.CLOSE);
tabItem1.setText("Tab 1");
Label lab2 = new Label(newTabFolder, 0);
lab2.setText("Hello World");
tabItem1.setControl(table);
tabItem1.setControl(lab2);

I am trying to have a CTabItem which has a table and some labels and textfields

But the problem arising is that any item/widget is added by use of setControl(Control control) function. And I cannot pass more than two controls. The code above adds a table first and then over writes it with the label, hence showing only one item at a time.

And I want both things at one time.

I have also tried to see if I might add things to an object of Control and then pass that control to setControl() function but I could not find any function by which I can add items/widgets to control
please tell me how to do this.

final Composite compositeInTab = new Composite(newTabFolder, SWT.NONE);
        compositeInTab.setLayout(new FillLayout());
        table = new Table(compositeInTab, SWT.V_SCROLL);

        btn1.addMouseListener(new MouseAdapter()
        {
            public void mouseDown(MouseEvent e)
            {
                /*JUST CREATING A TABLE AND MANAGING IT*/
                String[] titles = {"System Code","Domain Name","Organizational Unit","Organization Name"};
                for(int i=0; i<titles.length; i++)
                {
                    TableColumn column = new TableColumn(table, SWT.CENTER, i);
                    column.setText(titles[i]);
                    column.setWidth(150);
                    column.setMoveable(true);
                    column.setResizable(true);
                }
                for(int i=0; i<50; i++)
                {
                    TableItem item = new TableItem(table, 0);
                    item.setText(0, ""+i);
                    item.setText(1, ""+i);
                    item.setText(2, ""+i);
                    item.setText(3, ""+i);
                }
                for (int i = 0; i < titles.length; i++) 
                {
                    table.getColumn(i).pack();
                }
                table.setHeaderVisible(true);
                table.setSize(table.computeSize(SWT.DEFAULT, 200));
                table.setLinesVisible(true);
                /*CREATING OF TABLE COMPLETE*/

                compositeForTabFolder.setLayout(new GridLayout());
                compositeForTabFolder.setBounds(280, 0, 500, 450);
                newTabFolder.setUnselectedCloseVisible(false);

                CTabItem tabItem1 = new CTabItem(newTabFolder, SWT.CLOSE);
                tabItem1.setText("Tab 1");
                Label lab2 = new Label(compositeInTab, 0);
                lab2.setText("Hello World");
                Label lab3 = new Label(compositeInTab, 0);
                lab3.setText("Bye Bye World");
                tabItem1.setControl(compositeInTab);

                newTabFolder.setBounds(0, 0, 500, 300);
            }
        });

Image

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T04:04:06+00:00Added an answer on June 9, 2026 at 4:04 am

    You could use a Composite, then add everything you want to this Composite and afterwards use setControl(composite).

    This way, you will only have to add ONE widget via setControl() but this widget can have multiple children.

    There is a good example here.

    Here is the sample code from this site (slightly modified):

    public static void main(String[] args) {
        Display display = new Display();
        final Shell shell = new Shell(display);
        final TabFolder tabFolder = new TabFolder(shell, SWT.BORDER);
        for (int i = 0; i < 6; i++) {
          TabItem item = new TabItem(tabFolder, SWT.NONE);
          item.setText("TabItem " + i);
          item.setToolTipText("This is my tab" + i);
    
          Composite composite = new Composite(tabFolder, SWT.NONE);
          composite.setLayout(new FillLayout());
          new Button(composite, SWT.PUSH).setText("Button");
          new Text(composite, SWT.BORDER).setText("TextField");
          new Label(composite, SWT.NONE).setText("Label");
    
          Table table = new Table(composite, SWT.NONE);
          table.setHeaderVisible(true);
    
          new TableItem(table, SWT.NONE).setText("TableItem");
    
          item.setControl(composite);
    
        }
        tabFolder.pack();
        shell.pack();
        shell.open();
        while (!shell.isDisposed()) {
          if (!display.readAndDispatch())
            display.sleep();
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can the width of the tab-header of a CTabItem be set arbitrary? Thnx in
In my RCP app, I have a tab folder widget. Each of the tab
I am trying to created a scrolled composite that has a composite with a
I'm using a CTabFolder to let the user edit a group of elements. However,
I have got some CTab items, which I want to measure, especially I need

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.