Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

JTable input not correctly input-ted when a button is pressed

 
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hey guys,
i got a problem with my application. in my JTable, when I enter a value in a cell, and later press a button to update it, the value won't be properly input-ted into the corresponding cell unless I press the ENTER key after i finish typing the value!
so now i have to *remember* to press ENTER everytime i want to update anything in the table because if i don't, the value enter just before the "update" button is pressed won't be inside.
how do i deal with this problem? do i unfocus the table when the button is pressed, or what? how did u guys deal with this problem?
 
Ranch Hand
Posts: 148
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In your button's actionperformed code , add the following code as first line:
table.getCellEditor().stopCellEditing();
what this does is makes the table's default cell editor to stop editing & stores the value, now you can call tablemodel.getDataVector() ..etc. & get the required value.
This should solve your problem ,Chin.
 
Chin Loong
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks, vinod!
 
CAUTION! Do not touch the blades on your neck propeller while they are active. Tiny ad:
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
    Bookmark Topic Watch Topic
  • New Topic