• Post Reply Bookmark Topic Watch Topic
  • New Topic

Button event not working while image is moving  RSS feed

 
Vijraj Bhargav
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i have this code. in this code an image is moving left to right with moveImage method and moves right to left with moveimg method in the code. what i want now is to work a button event. there is a button in code, i want when i click the button it should do its job. but it's not doing.. here the code is:

 
Winston Gutkowski
Bartender
Posts: 10573
65
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Vijraj Bhargav wrote:i have this code.

Vijraj,

You're likely to get much better response if you don't include redundant code when you post (ie, all that stuff that's commented out).

Also: In future, please check for the appropriate forum before you post. Both your threads have been moved to our Swing forum.

Thanks.

Winston
 
Rob Camick
Ranch Hand
Posts: 2787
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Don't override the update() or paint() methods of a JFrame. That is old logic used in AWT. That is not the way custom painting is done when using Swing.

Instead you should override the paintComponent() method of a JPanel (or JComponent) and then add the panel to the frame.

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