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

  • Home
  • SEARCH
  • 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 6906173
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T08:16:33+00:00 2026-05-27T08:16:33+00:00

I’ve been messing with windowbuilder pro lately. I’ve lately run into the problem of

  • 0

I’ve been messing with windowbuilder pro lately. I’ve lately run into the problem of figuring out how to add items to a list when a button is pressed. The error is that it can’t seem to access list. Here is the code I have:

package wb;

import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import swing2swt.layout.BorderLayout;
import org.eclipse.swt.widgets.TabFolder;
import org.eclipse.swt.widgets.TabItem;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.MouseAdapter;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.layout.FormLayout;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.List;
import swing2swt.layout.BoxLayout;
import swing2swt.layout.FlowLayout;

public class WindowBuilderTest {

/**
 * Launch the application.
 * @param args
 */
public static void main(String[] args) {
    try {
        WindowBuilderTest window = new WindowBuilderTest();
        window.open();
    } catch (Exception e) {
        e.printStackTrace();
    }
}

/**
 * Open the window.
 */
public void open() {
    Display display = Display.getDefault();
    Shell shell = new Shell();
    shell.setSize(450, 300);
    shell.setText("SWT Application");
    shell.setLayout(new BorderLayout(0, 0));

    TabFolder tabFolder = new TabFolder(shell, SWT.NONE);

    TabItem tbtmListTest = new TabItem(tabFolder, SWT.NONE);
    tbtmListTest.setText("List Test");

    Composite composite = new Composite(tabFolder, SWT.NONE);
    tbtmListTest.setControl(composite);
    composite.setLayout(new BorderLayout(0, 0));

    Composite composite_1 = new Composite(composite, SWT.NONE);
    composite_1.setLayoutData(BorderLayout.SOUTH);
    composite_1.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 5));

    Button button = new Button(composite_1, SWT.NONE);
    button.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseUp(MouseEvent arg0) {
            list.add("Herpity Derpity"); //It screws up here.
        }
    });
    button.setText("+");

    Button button_1 = new Button(composite_1, SWT.NONE);
    button_1.setText("-");

    List list = new List(composite, SWT.BORDER);
    list.setLayoutData(BorderLayout.CENTER);

    TabItem tabItem = new TabItem(tabFolder, SWT.NONE);
    tabItem.setText("New Item");

    Button btnNewButton = new Button(shell, SWT.NONE);
    btnNewButton.setLayoutData(BorderLayout.SOUTH);
    btnNewButton.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseUp(MouseEvent arg0) {
            System.exit(0);
        }
    });
    btnNewButton.setText("Quit");

    shell.open();
    shell.layout();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch()) {
            display.sleep();
        }
    }
    }
}

This is my first time asking a question on stackoverflow, so I have high hopes. I put my limited patience in the hands of you guys.

  • 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-27T08:16:33+00:00Added an answer on May 27, 2026 at 8:16 am

    Declare list above your call to addMouseListener, and declare it as final, e.g. final List list = ....

    • 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 am currently running into a problem where an element is coming back from
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I have a jquery bug and I've been looking for hours now, I can't
this is what i have right now Drawing an RSS feed into the php,
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
That's pretty much it. I'm using Nokogiri to scrape a web page what has

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.