Solved

Cell listener on JTable

Posted on 2006-11-08
3
5,065 Views
Last Modified: 2008-01-09
Hi,

I have a JTable and implemented a model. I implemented the setValueAt(...) method to reflect the user input in my model. However, the setValueAt(...) method is not reliable enough, because it only fires when the user actually LEAVES the cell. If he does some input and then hits a button, the model is still in the old state. How can I force each and every input the user makes to be reflected in my model? Do I have to add a listener that updates the model at user input? In that case, can you show me an example, cause Im a Swing noob :)

Thanks in advance!

Regards,
Lizzz
0
Comment
Question by:lizzzard
3 Comments
 
LVL 25

Accepted Solution

by:
Tomas Helgi Johannsson earned 75 total points
ID: 17897852
    Hi!

Take a look at this example : http://www.java2s.com/Code/Java/SWT-JFace-Eclipse/editacellinaSWTtableinplacefancy.htm
You can extend the e.type in the HandleEvent to catch other SWT events.
Hope it helps.

Regards,
  Tomas Helgi
0
 
LVL 14

Expert Comment

by:hoomanv
ID: 17900454
Try
    jTable.getCellEditor().stopCellEditing();
0
 

Author Comment

by:lizzzard
ID: 17905381
I tried stopCellEditing, but that doesnt work. It doesnt fire when I click the a button right after editing the cell, but not leaving it. I used some leads presented by Thomas' link, and implemented an editor off that.

Many thanks for your suggestions
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
groupSum6 challenge 6 76
Printing to a specific printer tray (HP 806dn printer) 3 83
sites similar to codingbat to improve coding hanson skills 3 39
maven project error 5 44
INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…

930 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now