my dog learned polymorphism*
The moose likes Swing / AWT / SWT and the fly likes tableChanged event of TableModelListener Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "tableChanged event of TableModelListener" Watch "tableChanged event of TableModelListener" New topic
Author

tableChanged event of TableModelListener

James Peter
Ranch Hand

Joined: Sep 15, 2010
Posts: 115
Hi All,

I am having problem in retrieving data from InteractiveTableModel. Code is like below (part of entire code)



I have one button to print content of table. When I enter the value in table cell and without pressing Enter Key if I click print button I found that content of a cell which is having focus at present is not getting retrieved. I also noticed that tableChanged method is not being called while wevkey in values in cell.

Please let me know how to get rid of this problem.

Thanks
Peter


Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19651
    
  18

James Peter wrote:When I enter the value in table cell and without pressing Enter Key if I click print button I found that content of a cell which is having focus at present is not getting retrieved.

Call where table is the variable referring to your JTable. That will cause the cell editing to stop (terminate) whenever the JTable loses focus, like when a button is pressed.

I also noticed that tableChanged method is not being called while wevkey in values in cell.

That's because the table cell editor hasn't committed its current value to the JTable yet. It won't until you press Enter, or until you "flush" the data to the TableModel manually (using setValueAt).


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
James Peter
Ranch Hand

Joined: Sep 15, 2010
Posts: 115
Hi Rob,

It really worked. thanks a lot.


Peter
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19651
    
  18

You're welcome.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: tableChanged event of TableModelListener
 
Similar Threads
JTable displaying input data onto console
Having problem in resetting the value of JTable
How to set focus on submit button on press of enter key
TableModelEvent question: fires AFTER user has navigated away from cell, not what I need
Update database by editing the cells in JTable