Solved

Cell listener on JTable

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

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

707 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

16 Experts available now in Live!

Get 1:1 Help Now