Glitch...

Posted 22 December 2009 - 07:09 AM

I can't solve this glitch and it would be hard to explain unless you have a program that can compile this code such as dr.java. So the problem is when you click on a Jbutton(game), the action listener i put on that button doesn't show up unless you minimize the window and restore it back to normal.
Here is my code

Re: Glitch...

Posted 22 December 2009 - 12:13 PM

cool its working now thnx

I have one more question though, since when u click on the game button (Jbutton) it shows the action listener but when u accidentally click it twice it will overlap the previous content of action listener. How do i limit that or stop it from overlapping the previous content when u press the jbutton more than once?

Re: Glitch...

Posted 22 December 2009 - 02:33 PM

funstufflol, on 22 Dec, 2009 - 11:13 AM, said:

cool its working now thnx

I have one more question though, since when u click on the game button (Jbutton) it shows the action listener but when u accidentally click it twice it will overlap the previous content of action listener. How do i limit that or stop it from overlapping the previous content when u press the jbutton more than once?

well a quick fix to this is to create a boolean that would be set to false once your action starts, and set to true once it ends so that way, it shows availability. If you press it, switches to false thus allowing the user to press the button but nothing would happen.

Otherwise, same concept, just enable it or disable it. That would be a little cleaner and user-friendly approach

Re: Glitch...

Posted 22 December 2009 - 03:01 PM

Not a good idea to add a JComponent in an ActionListener
Better to add it in your constructor and make it setVisible(false);
in the actionPerformed() method just set its text (if required) and setVisible(true);