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 JButton slow response time Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JButton slow response time" Watch "JButton slow response time" New topic
Author

JButton slow response time

J Vazquez
Greenhorn

Joined: Aug 24, 2008
Posts: 6
I am experiencing about a 2 second delay when i click on the jbuttons in my swing application. The Gui application is an image program, with each button containing and ImageIcon. The Panel that all the buttons are on implements DropTargetListener(as I just drag images to the panel and the buttons are dynamically created)

I was wondering what suggestions there might be for me to speed up the responsiveness. It is only with button on this panel that I am experiencing this problem. I have another panel with jbuttons with images pulled from the web that are very "snappy." Thanks in advance for any suggestions.

-Juan
pete stein
Bartender

Joined: Feb 23, 2007
Posts: 1561
Your problem could be due your tying up the EDT, the Event Dispatch Thread, and if so, you'll have to take care to keep the EDT free of busy work.

What I want to know is what actions occur when the button is pressed? Do these actions take a bit of time or strain the processor? If so, do you need to call these actions within a background worker thread?
J Vazquez
Greenhorn

Joined: Aug 24, 2008
Posts: 6
as of right now, my JButtons just print out "Button was clicked"
pete stein
Bartender

Joined: Feb 23, 2007
Posts: 1561
Your best bet here is to post your code. Most here will not want to see your whole program, but rather to have you condense your question/problem into a single small class that is compilable by any and all of us, and demonstrates your problem. In other words, a [Short, Self Contained, Correct (Compilable), Example or SSCCE|http://homepage1.nifty.com/algafield/sscce.html] .

Remember, the code should be compilable and runnable for many of us to be able to understand it fully.

Also, when posting your code, please use code tags so that your code will retain its formatting and be readable. To do this, you will need to paste already formatted code into the forum, highlight this code, and then press the "code" button at the top of the forum Message editor prior to posting the message. You may want to click on the Preview tab to make sure that your code is formatted correctly. Another way is to place the tag [code] at the top of your block of code and the tag [/code] at the bottom, like so:



good luck
[ August 26, 2008: Message edited by: pete stein ]
J Vazquez
Greenhorn

Joined: Aug 24, 2008
Posts: 6
ok, let me work on it. As of right now the program as a whole is huge. Thank you for your help
-Juan
J Vazquez
Greenhorn

Joined: Aug 24, 2008
Posts: 6
here is my code... I have a resizeImage() method that I tried in place of the getScaledInstance method that generates a java heap error, which I have posted in different thread(i think I am some how leaking memory). I have verified that I have the same delay problems when I drag images to the panel. The images are approx 2MB each (3072x2048). Thank you for your help.

 
 
subject: JButton slow response time
 
Similar Threads
Resizing Layout with change in Screen Resolution
Refreshing a JScrollPane...
How to use FocusListener for ConfigOptions Panel
Static / Dynamic JButtons and JPanels
Enter Key Behavior