aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes JSpinner arrow listener Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JSpinner arrow listener" Watch "JSpinner arrow listener" New topic
Author

JSpinner arrow listener

Mathias Nilsson
Ranch Hand

Joined: Aug 21, 2004
Posts: 367
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


SCJP1.4
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
not sure I understand the question, but this will give you access to the arrow buttons

Mathias Nilsson
Ranch Hand

Joined: Aug 21, 2004
Posts: 367
Thanks you very much. This was exactly what I was looking for

// Mathias
Floréal Cabanettes
Greenhorn

Joined: Aug 19, 2014
Posts: 3
EDIT : I see this is ActionListener, ok, I have understand. You can delete my post.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38873
    
  23
Welcome to the Ranch

What attracted you to an old thread?
Floréal Cabanettes
Greenhorn

Joined: Aug 19, 2014
Posts: 3
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

Joined: Oct 13, 2005
Posts: 38873
    
  23
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

Joined: Aug 19, 2014
Posts: 3
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.
 
 
subject: JSpinner arrow listener