Solved

Cell listener on JTable

Posted on 2006-11-08
3
5,075 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Selenium docs api java index 3 63
Eclipse Java import and method not resolved 4 73
Java class and jar 3 41
Where to place postgres JDBC driver jar on tomcat 8 24
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…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

679 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