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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T04:10:36+00:00 2026-06-08T04:10:36+00:00

In my form I have a JTable with a TableModelListener. The tableChanged method updates

  • 0

In my form I have a JTable with a TableModelListener. The tableChanged method updates the logic on my JButtons. This all works correctly. When a user edits a value in a cell in the jtable – the tableChanged method executes and the buttons are refreshed accordingly.

The problem I am having and it is a show stopper. The JTable displays objects and some attributes of the object. The user selects the objects from the application.
If I there is a object selected and being displayed in the jtable. If that user changes a attribute value in the application and not edit it in the JTable. The jtable is still refreshed and the changed value is displayed. But a TableModelEvent is not taking place and my button logic is never refreshed.

I have looked at TableCellListeners – but that is still looking for a edit in the table. So I don’t think that will work here.

How can I tell that something has changed and the Table has been updated without a Event taking place in the jtable itself?

EDIT: Placing some of the jtable code

This is in my base dialog class

selectTable = new JTable(SingletonSelectTable.getInstance());
selectTable.getModel().addTableModelListener(this); 
selectTable.setDefaultRenderer(Object.class, new DefaultTableCellRenderer() {
     public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
        Component comp = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
        Font font = comp.getFont();
        if (SingletonSelectTable.getInstance().isCellBold(row, column) == true){
           comp.setFont(font.deriveFont(Font.BOLD));
        }
     return comp;
     }
  });

selectTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
selectTable.setCellSelectionEnabled(false);
selectTable.setRowSelectionAllowed(true);
selectTable.setColumnSelectionAllowed(false);
JScrollPane ScrollPane = new JScrollPane(selectTable);

the tableChanged method

public void tableChanged(TableModelEvent e) {
  setRemoveButtonVisibility();
  setRemoveAllButtonVisibility();
  setCommentButtonVisibility();
  setOKButtonEnabledStatus();

}

my singleton class

public class SingletonSelectTable extends AbstractTableModel {

I hope this helps

  • 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-06-08T04:10:38+00:00Added an answer on June 8, 2026 at 4:10 am

    How can I tell that something has changed and the Table has been updated without a Event taking place in the jtable itself?

    There is never an event in the JTable. It is the underlying TableModel that changes, and it is the TableModel that fires an event.
    The JTable registers a listener to the TableModel so it knows when it should update the displayed table content.

    So if you are saying that the JTable gets updated (automatically, so without you scrolling/selecting/hovering/…) means that the TableModel does fire an event, meaning you can also listen for it.

    In the scenario an element of your TableModel is changed in your application, something should fire the TableModelEvent from the TableModel. Typically this is done by either letting the TableModel listen for changes in the objects it contains, or letting the code that changes the object also notify the TableModel that the underlying data has been changed. Either way, the TableModel needs to fire an event, so there is no reason why your listener would not receive it, unless it is simply not fired (meaning an incorrect TableModel).

    My best guess, based on your comments, is that you have an incorrect implementation of your TableModel and that your TableModel simply does not fire an event, and that the JTable gets updated ‘by accident’ (in my experience is a JTable rather robust for missing events, certainly when no rows are added/removed … definetely compared to a JTree)

    The getValueAt() method picks up the change and then updates the jtable

    This really sounds incorrect. The getValueAt() method is normally called by the JTable after it receives an event. Thanks to the event, the JTable knows it must be updated so it queries the model for the new data. So the getValueAt method does not pick up the change, but gets called as a result of the change.

    I would strongly suggest to take a look at the Swing table tutorial, and certainly the sections about Creating a table model, Listening for data changes and Firing data change events

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

Sidebar

Related Questions

I have this code which works. $(document).ready(function(){ $('form').live('submit', function(){ // have to do it
I have a master/detail form with a JTable on top, and all the JTextFields
I have a login form for my website. This login form have two text
I have added a checker to ensure that all fields in a form have
I have a form to add new Appartments, and in this form I have
I have form where user submits field. Field can have letters, numbers, and punctuation.
I have a problem. I have form inside a fancybox. This form have a
I've created a search form for a script in php. Basicaly this form have
I create form and controller this form have some validation constrains using Hibernate validator.
I have this JTable having an AbstractTableModel as its model. The initial contents are

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.