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 7499841
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T19:57:44+00:00 2026-05-29T19:57:44+00:00

I’m attempting to design a SWT UI as a total newbie to both SWT

  • 0

I’m attempting to design a SWT UI as a total newbie to both SWT and UI programming in general. Based on the snippets in the SWT documentation I’ve written the following:

    Display.setAppName("App Name");

    Display display = new Display();

    Shell shell = new Shell(display);
    shell.setLayout(new GridLayout());

    Group group = new Group(shell, SWT.DEFAULT);
    group.setLayout(new GridLayout());

    for (int i = 0; i < 3; i++)
        new Button(group, SWT.PUSH).setText("ABC" + i);

    new Label(group, SWT.SEPARATOR | SWT.VERTICAL);

    for (int i = 0; i < 3; i++)
        new Button(group, SWT.PUSH).setText("ABC" + i);

    new Label(group, SWT.SEPARATOR | SWT.HORIZONTAL);

    Table table = new Table(group, SWT.MULTI | SWT.BORDER | SWT.FULL_SELECTION);
    table.setLinesVisible(true);
    table.setHeaderVisible(true);
    GridData data = new GridData(SWT.FILL, SWT.FILL, true, true);
    table.setLayoutData(data);

    for (String title : new String[] { "A", "B", "C", "D", "E", "F", "G" })
        new TableColumn(table, SWT.NONE).setText(title);

    for (int i = 0; i < 128; i++) {
        TableItem item = new TableItem (table, SWT.NONE);
        item.setText(0, "123");
        item.setText(1, "234");
        item.setText(2, "345");
        item.setText(3, "456");
        item.setText(4, "567");
        item.setText(5, "678");
        item.setText(6, "789");
    }

    for (TableColumn column : table.getColumns())
        column.pack();

    shell.pack();
    shell.open();

    while (shell.isDisposed() != true)
        if (display.readAndDispatch() != true)
            display.sleep();

    display.dispose();
}

This results in something like:

ABC1
ABC2
ABC3
|
ABC1
ABC2
ABC3
---
Table

If I change the layout on the group to RowLayout() but don’t change the table’s GridData() to RowData() I get a class cast exception. If I change it to RowData() I get something that looks like:

ABC1 ABC2 ABC3 | ABC1 ABC2 ABC3 ---- Table

What I want is this:

ABC1 ABC2 ABC3 | ABC1 ABC2 ABC3
-------------------------------
             Table

Any suggestions?

  • 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-05-29T19:57:46+00:00Added an answer on May 29, 2026 at 7:57 pm

    Set the shell layout to gridLayout with a width of 2. Then when you make your table, set the gridData horizontal span to 2

    Mostly from memory, untested

    Shell myshell = new Shell(display, SWT.NONE);
    GridLayout twoColumn = new GridLayout();
    twoColumn.numColumns = 2;
    myshell.setLayout(gl);
    
    Group g1 = new Group(myshell, SWT.DEFAULT);
    Group g2 = new Group(myshell, SWT.DEFAULT);
    
    GridData twospan = new GridData(SWT.FILL, SWT.FILL,true,true);
    twospan.horizontalSpan = 2;
    
    Table t1 = new Table(myshell, SWT.DEFAULT);
    t1.setLayoutData(twospan);
    

    This should set up your GridLayout to have two columns, so you add g1 and it goes top left, g1 and it goes top right. Then you specify that t1 is going to take up two columns, so when you add it it takes the whole second row. It’s also ignoring your separator label for now.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a small JavaScript validation script that validates inputs based on Regex. I
Configuring TinyMCE to allow for tags, based on a customer requirement. My config is
I am trying to understand how to use SyndicationItem to display feed which is
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
In my XML file chapters tag has more chapter tag.i need to display chapters
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I would like my Web page http://www.gmarks.org/math_in_e-mail.txt on my Apache 2.2.14 server to display
I am writing an app with both english and french support. The app requests

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.