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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T08:07:17+00:00 2026-05-23T08:07:17+00:00

I am trying to bind an ArrayList of objects to a Java SWT List

  • 0

I am trying to bind an ArrayList of objects to a Java SWT List widget. This is what I have:

    DataBindingContext bindingContext = new DataBindingContext();
    //
    myModel= new WritableList(buses, MyObject.class); 
    IObservableList listWidgetObs = SWTObservables.observeItems(listWidget);
    bindingContext.bindList(listWidgetObs , myModel, null, null);
    //
    return bindingContext;

But somehow, it doesn’t seem to work. I have been trying for a long time but still with no luck. This is my first time trying data binding in Java. How do I bind an ArrayList as the data provider of an SWT List widget and then bind it to the value of a method call getName() in MyObject class?

Thanks!

  • 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-23T08:07:18+00:00Added an answer on May 23, 2026 at 8:07 am

    From your example, it looks like the model list (myModel) contains objects of type MyObject. But this is wrong as the content list of an SWT List must by be Strings.

    You have (at least) three choices:

    • the objects in the list must be of type String so you must convert the objects as you create the observable list, or
    • your must supply a UpdateListStrategy in bindingList(...), or
    • you bind with a ListViewer with a LabelProvider

    The choice depends on whether the objects of myModel can change dynamically.

    I usually choose the second option when possible as I try to not mix both databinding and JFace unless it is really, really needed. The alternative can sometimes get some rather ugly notification/listener chains…

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

Sidebar

Related Questions

I'm trying to bind a list of custom objects to a WPF Image like
I have a custom class Contact . I am trying to bind a List<Contact>
I trying to bind List to Listbox. And at the Button1Click method new instance
Im trying to bind a list with datetime objects to my repeater. if (e.Item.ItemType
I'm trying to bind a list of objects to a list box. Each object
I'm trying to bind a list of integers into an SQLTemplate IN clause like
This is the exception that I'm getting when I'm trying to bind to a
i am trying to use this code to bind my asp.net menu control to
I have a ASP.net gridview that I am trying bind to. My DataSource has
I am trying to bind my view model to the Html.Grid. I have set

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.