Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

JButton problem...  RSS feed

 
Jeff Smith
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I need some help. I have a JButton, and I want it so that when the user clicks the button, and holds the button down, the event keeps happening.
I'm trying to create one of those little spinner like things that you see in windows programs, where there's a text field, and to the right there's an increment and decrement button.
The way mine works right now is that when the user clicks the button, the text field value goes up by one, but doesn't keep going up even if the button is held down, which isn't what I want. Any help would be greatly appreciated....
Thanks,
Jeff
 
Matt Senecal
Ranch Hand
Posts: 255
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here's an idea I haven't tried, and may not work:
Create a MouseListener that listens for events on button 1 (the left button). In the body of the listener, do a check to see if the button is selected. If true, increment your counter by 1.
Something like this:

Originally posted by Jeff Smith:
I need some help. I have a JButton, and I want it so that when the user clicks the button, and holds the button down, the event keeps happening.
I'm trying to create one of those little spinner like things that you see in windows programs, where there's a text field, and to the right there's an increment and decrement button.
The way mine works right now is that when the user clicks the button, the text field value goes up by one, but doesn't keep going up even if the button is held down, which isn't what I want. Any help would be greatly appreciated....
Thanks,
Jeff

 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!