GeeCON Prague 2014*
The moose likes JDBC and the fly likes saving data to database without pressing button Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Databases » JDBC
Bookmark "saving data to database without pressing button" Watch "saving data to database without pressing button" New topic
Author

saving data to database without pressing button

elwin Ilam
Greenhorn

Joined: May 02, 2011
Posts: 11
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

Joined: May 02, 2011
Posts: 11
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 (:
 
GeeCON Prague 2014
 
subject: saving data to database without pressing button