Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Cell listener on JTable

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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
servlet doXXX methods 3 62
Adding multiple JVM environments to RedHat 6 7 48
Java basic valueOf question 1 29
jsp error 6 26
For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
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…
The viewer will learn how to implement Singleton Design Pattern in Java.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

860 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