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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T10:44:42+00:00 2026-05-15T10:44:42+00:00

In Netbeans, I created a JTable and bound it’s values to a JPA result

  • 0

In Netbeans, I created a JTable and bound it’s values to a JPA result set. This works great. The query contains a parameter which I set in the pre-create box of the “query result” component. So just before Netbeans creates the query result I write this:

myQuery.setParameter("year", "1997");

This works fine. Now, I have an event handler which is supposed to change the parameter and display the new values in the table. So I do this:

myQuery.setParameter("year", "2005");
myResultList.clear();
myResultList.addAll(myQuery.getResultList());
jTable1.updateUI();

This works, but it feels wrong to me. Note: The result set is bound to the table. So I was hoping there was something like this:

myQuery.setParameter("year", "2005");
myResultList.refresh();

Is there something like this?

  • 1 1 Answer
  • 2 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-15T10:44:42+00:00Added an answer on May 15, 2026 at 10:44 am

    I finally figured it out…

    The root of the problem lies in the JTableBinding class. Here’s the important excerpt of the API doc:

    If the List is an instance of ObservableList, then changes to the List contents (such as adding, removing or replacing an object) are also reflected in the JTable. Important: Changing the contents of a non-observable List while it is participating in a JTableBinding is unsupported, resulting in undefined behavior and possible exceptions.

    And indeed, changing the list contents while it’s not an observable list has weird behaviour in the resulting UI. If, for example, your initial query returns 1000 rows, and after the update the list only contains 100 rows, then the bound JTable still lets you try to scroll past the results. And the UI “hangs” for a short while.

    In fact, when using JPA in Netbeans, and you use the appropriate components from the pallette, then you can easily fix this. The QueryResult “widget” has a checkbox labelles “observable”. Check this one and you’re done. Now all changes to the result will be reflected automatically in the JTable. So you can simply do:

    myQuery.setParameter("year", "2005");
    myResultList.clear();
    myResultList.addAll(myQuery.getResultList());
    

    without doing anything else.

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

Sidebar

Related Questions

I use JTable GUI component with NetBeans. I want to create multi-line headers I
If I open my application in both eclipse and netbeans (having created the file
We have a netbeans project that has an xsd that we use to create
Netbeans tells me it's bad to access a static method from a non static
In Netbeans (I have the 6.5 version), in the project properties under Application> Webstart
I learned today that NetBeans 6.5 should have an on-the-fly compilation of (single) Java
By default netbeans stores it's settings in a directory called .netbeans under the user's
Using the debugger in Netbeans 6.1, I'd like to step into a method of
I'm using NetBeans, trying to change the familiar Java coffee cup icon to a
I'm using NetBeans 6.5 for developing PHP and I have xdebug setup. Is there

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.