473,396 Members | 2,002 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

identify each character entred into the cell of jtable

5
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!
Apr 8 '09 #1
6 2858
JosAH
11,448 Expert 8TB
@raggwd
You are probably using a JTextField for your editor. Add an InputMethodListener and a FocusListener and take appropriate actions when such an event is fired.

kind regards,

Jos
Apr 9 '09 #2
raggwd
5
Thank you for the reply.I am using a default editor...i.e label not textbox.
I will try with what you hav said and let you know the outcome.
My requirement is something similar to what happens in excel.
when we type in a cell of an excel sheet the type char will be displayed both in the cell and in the textbox present on top.Here the text box on top is update every time a character is enter .But in the jtable the update happens only when we press enter.
Apr 9 '09 #3
raggwd
5
hi,
Got a solution for it
created custom cell editor with jtextbox component as the cell and added key listener to the component....So now its working.
Thank tou for the reply josah... :)
Apr 9 '09 #4
JosAH
11,448 Expert 8TB
@raggwd
You're welcome of course but I doubt if your approach works: try to copy and paste a piece of illegal text in your JTextField; there'll be no KeyEvents but there is new text ...

kind regards,

Jos
Apr 9 '09 #5
raggwd
5
You are right...It didnt work when i pasted the data.
what shall i do..And where should i add InputMethodListener and a FocusListener.For the table or the cell of the table.
Apr 10 '09 #6
JosAH
11,448 Expert 8TB
@raggwd
Your TableCellEditor knows about that JField; add your listeners to that JField.

kind regards,

Jos
Apr 10 '09 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: asd | last post by:
I need to make the cells in the 1st column look like the column header. I tried the following code but it didn't change anything: private void rendererTest() { TableColumn column =...
1
by: raysaun | last post by:
I am trying to set a TableCellEditor for a JTable, however, the editor never seems to get called. I can not even get a simplified version (below) to work. When I put a breakpoint on the return...
0
by: nuria | last post by:
hi, I have an editable JTable, when you are editing it and press F8 shows a dialog and then go again to the JTable window but the focus goes to a JtextField component, go with the tab for the...
1
by: Andrea Sansottera | last post by:
Hi fellows, I was wondering if in the Java API there's a way to easily map a disconnected RowSet to a JTable... I have looked at the doc but i did not found anything. What I want is simply do...
1
by: onsir | last post by:
I have code like this, but still wrong. how to show data from database in JTable. package my.JavaNetBean; import java.sql.*; import java.io.*; import java.sql.Connection; import...
0
by: =?Utf-8?B?UmljaA==?= | last post by:
In a datagridview, the first column header cell is columnHeader(0), which is immediately to the right of the Top Left Corner Select All cell. And the first RowHeader cell is RowHeaderCell(0) which...
7
blazedaces
by: blazedaces | last post by:
Hi guys, what I'm I have is a jtable with boolean variables in the first column and text in the next two (checkboxes). I want my tableChanged method to make it so when I check one of the checkboxes...
0
by: san1014 | last post by:
Hi to all' I am using Java swings. I written a code to display a table. In the table i used Boolean.class type column. when i click the checkbox it value to be change from false to true....
1
by: thesti | last post by:
hi, can we change the color of the border of a cell / every cell in JTable? thx
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.