Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

tableChanged event

Posted on 2004-09-04
5
Medium Priority
?
549 Views
Last Modified: 2012-05-05
In a JTable when the user enters data in a cell & leaves the cell (by pressing tab or something), the tableChanged event gets fired (if I have a TableModelListener added to the JTable), what if the user didn't leave the cell and pressed another button directly (for example a save button), then the data will not be saved in the JTable (and thus will not be retrieved in its getValueAt() function), so what can I do?

I was thinking of programmatically processing the TAB key by the following piece of code:

DefaultFocusManager fm = new DefaultFocusManager();
fm.processKeyEvent(jtablex,KeyEvent.VK_TAB); //where jtablex is an object of class JTable

The problem with this code is that KeyEvent.VK_TAB is an integer not a KeyEvent object (and there is no overloaded function to take a component and a KeyEvent object)
0
Comment
Question by:mte01
[X]
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
  • 3
  • 2
5 Comments
 
LVL 3

Author Comment

by:mte01
ID: 11980287
An extra note is that the focus lost event would not work because the cell that the user is working on needs to lose focus (by pressing tab or something) not the JTable (which should still have the focus)
0
 
LVL 86

Accepted Solution

by:
CEHJ earned 1800 total points
ID: 11981887
Try calling stopCellEditing on the cell editor first
0
 
LVL 3

Author Comment

by:mte01
ID: 11982410
Amazing!! it did just the right thing.......although stopCellEditing is a boolean function (not a void) that I thought only returns whether the user has stopped editing or not. It seems that what it does is that it forces that editing of the JTable to get stopped programmatically, and thus the data that's edited gets saved.

Thank you very much...you really deserve it
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 11982415
8-)
0
 
LVL 3

Author Comment

by:mte01
ID: 11982519
I also have a few questions for you CEHJ...(I don't know if I am allowed to ask them by the moderator or not....). How old are you? Where do you live? How do you benefit from such programming expertise (i.e. what do you do in life)? What is the range of the amount of money that you can earn per month from such expertise? (I am asking this question because I am working on becoming one in the near future)

Thanks in advance
0

Featured Post

Build and deliver software with DevOps

A digital transformation requires faster time to market, shorter software development lifecycles, and the ability to adapt rapidly to changing customer demands. DevOps provides the solution.

Question has a verified solution.

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

Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
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.
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 …
Suggested Courses

722 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