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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T11:00:10+00:00 2026-05-25T11:00:10+00:00

I have JTable which elements property binded to List of objects, this is master

  • 0

I have JTable which “elements” property binded to List of objects, this is master table. There is also details table, which “elements” property binded to selectedElement in master table. I did it with help of NetBeans GUI builder. Now I try to get something like this:

SomeEntityType selectedObject= (SomeEntityType) masterTable.getSelectedElement ()

in source code, but there is no such property in JTable, only “getSelectedRow”. So, how can I get selected object from JTable binded to source (List of objects)?
I have read similar questions, but find only link on getValueAt(rowId,columnId) method, but in my task it doesn’t matter which column is selected, because full row is selected.

  • 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-25T11:00:10+00:00Added an answer on May 25, 2026 at 11:00 am

    don’t know about Netbeans, just know that it uses a version of Beansbinding, so the following certainly can applied somehow

    The whole idea of using a binding framework is that you never directly talk to the view, but fully concentrate on your model (or bean): some property of such a model is bound to a property of a view and your code only listens to changes in the the properties of your bean. “SelectedElement” is an artificial property of the binding (actually, of the JTableAdapterProvider, but that’s nothing you need to know :-), so bind your model property to that – here’s a snippet of doing so manually:

        // model/bean 
        public class AlbumManagerModel .. {
             // properties
             ObservableList<Album> albums;
             Album selectedAlbum;
    
             // vents the list of elements
             ObservableList<Album> getManagedAlbums() {
                  return albums;
             }
    
             // getter/setter
             public Album getSelectedAlbum() {
                  return selectedAlbum; 
             }
    
             public void setSelectedAlbum(Album album) {
                Album old = getSelectedAlbum();
                this.selectedAlbum = album;
                firePropertyChange("selectedAlbum", old, getSelectedAlbum());
             }
    
    
        }
    
        // bind the manager to a JTable
    
        BindingGroup context = new BindingGroup();
        // bind list selected element and elements to albumManagerModel
        JTableBinding tableBinding = SwingBindings.createJTableBinding(
                UpdateStrategy.READ,
                albumManagerModel.getManagedAlbums(), albumTable);
        context.addBinding(tableBinding);
        // bind selection 
        context.addBinding(Bindings.createAutoBinding(UpdateStrategy.READ_WRITE,
                albumManagerModel, BeanProperty.create("selectedAlbum"), 
                albumTable, BeanProperty.create("selectedElement_IGNORE_ADJUSTING")
        ));
        // bind columns 
        tableBinding.addColumnBinding(BeanProperty.create("artist"));
        ...
        context.bind();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Jtable on which I called the method table1.setAutoCreateRowSorter(true); . So this
In Java Swing I have created a JTable which uses a table model class
I have a standalone application in which I have a Jtable. In my table,
I have a JTable which is loaded from a data-structure using table model.The data-structure
I have a jTable which currently displays and allows editing of a database table,
I have a JTable for which I have made a table model. But on
I have a JTable which uses a custom TableModel to display a series of
I have a JTable and a TableRowSorter which I'd like to perform an operation
I have a JTable (extended) and an implementation of TableModel , in which I
I have a JTable with two columns and both are JComboBox, for this purpose

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.