Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JSpinner arrow listener

 
Mathias Nilsson
Ranch Hand
Posts: 367
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi!

I need to change the value only when I press one of the arrows in a JSpinner component.
How can I add a listener to the arrow buttons. I tried ChangeListener but it was not what I needed
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
not sure I understand the question, but this will give you access to the arrow buttons

 
Mathias Nilsson
Ranch Hand
Posts: 367
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks you very much. This was exactly what I was looking for

// Mathias
 
Floréal Cabanettes
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
EDIT : I see this is ActionListener, ok, I have understand. You can delete my post.
 
Campbell Ritchie
Sheriff
Posts: 48910
58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch

What attracted you to an old thread?
 
Floréal Cabanettes
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell Ritchie wrote:Welcome to the Ranch

What attracted you to an old thread?


Thank you !

I am interested by change the value only when I press one of the arrows in a JSpinner component, like Mathias Nilsson.

The code written by Michael Dunn works fine but buttons of the JSpinner have not the good Look & Feel. Indeed, I use the Nimbus Look & Feel but when I use this code, the buttons of the corresponding JSpinner have not this Look & Feel anymore.

If somebody know how du this without losing the Nimbus Look & Feel...

Thank you in advance for your help.

Floréal.
 
Campbell Ritchie
Sheriff
Posts: 48910
58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Now, that's an interesting question!

I am sure you can change the look'n'feel. Yes, there is a section about it in the Java Tutorials.
 
Floréal Cabanettes
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have tried this code :


to see if the up button looks now good, but the look and feel of this button has not changed.

Also, my main method of my maint class is this one :


So the nimbus Look & Feel is initialised and all the components except the JSpinner on which I set the UI to myUI have the good look.

I have read the tutorial, but I don't understand how make it to work...

Thanks for your help,

Floréal.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic