File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes Long pressed jbuttons Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Long pressed jbuttons" Watch "Long pressed jbuttons" New topic
Author

Long pressed jbuttons

ricky shaw
Greenhorn

Joined: Mar 21, 2011
Posts: 12
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

Joined: May 03, 2008
Posts: 4523
    
    5

Hi ricky, and welcome to the Ranch! Please BeForthrightWhenCrossPostingToOtherSites.
http://www.java-forums.org/awt-swing/40929-long-pressed-jbuttons.html


luck, db
There are no new questions, but there may be new answers.
ricky shaw
Greenhorn

Joined: Mar 21, 2011
Posts: 12
Sorry about that and it wont happen again.
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4523
    
    5

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

Joined: Mar 21, 2011
Posts: 12
Sorry for not being clear. Suppose you have a button A. Then a long press of A will give you :
a,ä,á
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4523
    
    5

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

Joined: Mar 21, 2011
Posts: 12
thank you a lot.....Finally got it....
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4523
    
    5

You're welcome, and I'm glad you sorted it out!

For the record, this is my test code.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Long pressed jbuttons
 
Similar Threads
GWT designer can't find
onKeyPress
Problems interrupting a thread
I don't doGet() it!
How can I make the QUOTE only quote the last thread ?