I'm trying to do the recording in the database using Swing. I want to ask user to answer on some math question by setting the value on slider. Then, when he clicks Submit button (I named it "potvrdi") the value from JSlider should be written in database. I wrote this in the init method:
It doesn't work. Where did I make a mistake?
Is it maybe problem with potvrdiMouseReleased method, should I use other method or to change this?
If you want to insert the value on button click use the right event handler.
Could you please post the code that handles the button click event?
It seems that you are inserting values in your db table when you change the JSlider value instead...
Joined: Apr 28, 2010
I think that it doesn't insert the value when I change slider's value since it inserts many same rows. It reacts on button. If I select 500 on slider and push the button, it inserts many rows that contain 500.
I didn't wrote button's click event How to write it?
The obvious first step would be to do some logging in the potvrdiMouseReleased method so that you know when it's invoked.
Joined: Apr 10, 2010
When you click the button what happens?
i see MouseEvents, ChangeEvents but not the one you need: ActionEvent
Your button fires, among others, ActionEvents. To Handle an ActionEvent you should write an ActionListener, i mean a class that implements ActionListener. This class could be the same class in which you build the GUI or another one.
I write just a skeleton, an example of the first option.