Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

about JSpinner...  RSS feed

 
Aron Jhed Amiscosa
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi there. i am now working with a JSpinner...

my question is, how do you listen on changes in the value of the spinner...



all i want to happen is...
everytime that i add the value of the JSpinner, the value of the iQty on the table will be deducted or added depending on the value of the JSpinner...

Note: The table contains items from a database table...

Can you give me some idea, or some sample codes for this one.. I really have no idea..
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
 
Aron Jhed Amiscosa
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


hi, thanks for your response. I've been there before i posted. i already set up the Spinner, what i cant figure out is how to make it work at the same time with the table.

i mean.

jspinner value + 1 makes a value -1 from the table... i cant seem to have an idea of linking the two of them...
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need to break the problem into multiple parts.

1) Figure out when the JSpinner value was changed. The link talks about this. Somewhere in your code you need to maintain the previous value so you can figure out the increment/decrement quantity
2) Update the table.
2 a) Update the DB as well since the values reflected in the table are coming from the DB. If the DB update fails, reset the spinner after giving the user some warning.

I would provide some customUpdate methods in the table model which will do the following
1) Accept the value to be incremented/decremented
2) Make a DB call to update the DB.
3) On success, update the local copy of the table data (save a db call here if you are caching a data copy). Make sure to fire the appropriate fireTableXXX methods so that the table view is updated automatically.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!