• Post Reply Bookmark Topic Watch Topic
  • New Topic

JTable anchor cell  RSS feed

 
pindur pandur
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am writing a spreadsheet application using a JTable, and I used the suggestions from http://javaalmanac.com/egs/javax.swing.table/AnchorEdit.html to set up an JTextField that mirrors the value in the anchor cell. My problem is that the text in the JTextField only shows up after the user presses enter, and I need it to show up as the user types. Any suggestions on how I could achieve this would be appreciated.
 
Campbell Ritchie
Sheriff
Posts: 55351
157
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sounds like what they talk about on the swing/GUI forum.

Have you tried KeyListeners on wherever your entry field is? Then you could use each KeyEvent, or whatever they call it, to update your JTextField.
If you look up the KeyListener interface in API it says there is a tutorial about it.

CR
 
Mark Spritzler
ranger
Sheriff
Posts: 17309
11
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yeah, actually the Swing forum is the best forum for this question. I;m gonna move it to that forum.

Mark
 
Brian Cole
Author
Ranch Hand
Posts: 947
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by pindur pandur:
My problem is that the text in the JTextField only shows up after the user presses enter, and I need it to show up as the user types.


By far the easiest way to do this is two have the two fields
(the one in the cell editor and the other one) share the same
document. Run this code to see what I mean.

It's possible to use a KeyListener (or better would be
a DocumentListener), but that would be a lot more work.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!