Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / GUI / July 2006

Tip: Looking for answers? Try searching our database.

problem reading JTable

Thread view: 
Foolad - 26 Jul 2006 18:22 GMT
Hello Again,
I have put a JTable in my JFrame to get some data from user using
it.There is also a JButton that
I read table cells (with DeafultTableModel.getValueof(i,j)) when user
clicks on it.But the proble is that
when user changes contents of a cell and focus is still on that cell ,
if user presses the button ,  data of that cell isn't updated.
Is any way to solve it?
Thanks
Thomas Fritsch - 27 Jul 2006 14:36 GMT
> I have put a JTable in my JFrame to get some data from user using
> it.There is also a JButton that
> I read table cells (with DeafultTableModel.getValueof(i,j)) when user
> clicks on it.But the proble is that
> when user changes contents of a cell and focus is still on that cell ,
> if user presses the button ,  data of that cell isn't updated.
The problem is, that in this case the cell editor's stopCellEditing()
method is not called. See also the API doc of CellEditor#stopCellEditing()

> Is any way to solve it?
In your JButton's action code you have to call stopCellEditing():
  JTable yourTable = ...;
  if (yourTable.isEditing()) {
    yourTable.getCellEditor().stopCellEditing();
    // may be you should also check the return value
  }

Signature

Thomas



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.