• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Long pressed jbuttons

 
ricky shaw
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I created a JApplet using java swing. I need help with long pressed buttons. If anyone could post an example that would be very helpful.
 
Darryl Burke
Bartender
Posts: 5148
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ricky, and welcome to the Ranch! Please BeForthrightWhenCrossPostingToOtherSites.
http://www.java-forums.org/awt-swing/40929-long-pressed-jbuttons.html
 
ricky shaw
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry about that and it wont happen again.
 
Darryl Burke
Bartender
Posts: 5148
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need to be much more specific for members here to be able to help you. This page has some useful guidelines:
http://www.coderanch.com/how-to/java/HowToAskQuestionsOnJavaRanch

Or is this what you wanted?
 
ricky shaw
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry for not being clear. Suppose you have a button A. Then a long press of A will give you :
a,ä,á
 
Darryl Burke
Bartender
Posts: 5148
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You'll want to add a MouseListener to the button and start / stop a javax.swing.Timer on mousePressed / mouseReleased. The Timer's ActionListener must cycle through the characters, possibly by cyclically incrementing an index to a String array. User feedback can be provided by setting the button's text.

An ActionListener added to the button can retrieve its text (or alternatively retrieve the currently indexed String).
 
ricky shaw
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank you a lot.....Finally got it....
 
Darryl Burke
Bartender
Posts: 5148
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're welcome, and I'm glad you sorted it out!

For the record, this is my test code.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic