Win a copy of Python Continuous Integration and Delivery this week in the Python 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
  • Liutauras Vilda
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Devaka Cooray
  • Junilu Lacar
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Tim Holloway
  • Claude Moore
  • Stephan van Hulst
Bartenders:
  • Winston Gutkowski
  • Carey Brown
  • Frits Walraven

saving data to database without pressing button  RSS feed

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys,

I've got a jTable which shows data from my sqlite database. There are 12 checkboxes above the jtable, which each represent a different set of data.
currently, if you select a checkbox and press load, the right set of data is loaded. if you press save the data is stored again in the database.

Now, would it be possible...to do the saving and loading without pressing the save and load buttons? If you just click on a checkbox the right set of data is loaded....and somehow saved if you change it.

my ideas so far:
- use an entry row. so all the data is stored if you enter an additional row, then the loading can be done with checking the checkboxes. However not really aesthetically pleasing.
- if a checkbox is selected, save the current data first, then load the new data. But there are loopholes here, when data does not get saved.

Could you give me some advice?
Thanks alot
Elwin

here is the code I'm currently using to save and load (from the GUI Panel).

Saving:


Loading:
 
elwin Ilam
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I figured something out.

Data is saved when table loses focus,
Data is loaded when checkboxes are statechanged.

It seems to work pretty good.
Only when the Cell editor is still on, things go wrong.
But we'll see about that after the weekend (:
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!