Results 1 to 2 of 2
- 02-07-2013, 03:50 AM #1Member
- Join Date
- Nov 2012
- Rep Power
Moving objects in paintComponent void
In my program, I hit the right arrow and the box should move over... However, this is not the case. I can not think of any good way to move this box. I have tried putting a while loop in the paintComponent method that checks for a boolean. Then when I hit the arrow, the boolean becomes true. This does not work. I know why, but I cant fix it. The problem is that when I add the class with the paintComponent void to a JFrame, it only runs through the void once to add graphics. How can I achive my goal?
If tl;dr. Here is my question in a nutshell.
I cant get my green box to move. Help.
- 02-07-2013, 05:41 AM #2
Re: Moving objects in paintComponent void
Moved from Advanced Java.
Lesson: Performing Custom Painting (The Java™ Tutorials > Creating a GUI With JFC/Swing)
How to Use Key Bindings (The Java™ Tutorials > Creating a GUI With JFC/Swing > Using Other Swing Features)
May be useful:
How to Use Swing Timers (The Java™ Tutorials > Creating a GUI With JFC/Swing > Using Other Swing Features)
Lesson: Concurrency in Swing (The Java™ Tutorials > Creating a GUI With JFC/Swing)
To get better help sooner:
SSCCE (Short, Self Contained, Correct (Compilable), Example)
Oh, and if you think this is an advanced question, then you ain't seen nothing yet!
dbIf you're forever cleaning cobwebs, it's time to get rid of the spiders.
- By Silversurfer20 in forum Java 2DReplies: 10Last Post: 04-05-2012, 09:32 AM
- By Thomask in forum Java AppletsReplies: 8Last Post: 02-17-2011, 06:23 PM
- By rsjava24 in forum AWT / SwingReplies: 1Last Post: 02-26-2010, 11:47 AM
- By Antigol in forum Java 2DReplies: 2Last Post: 08-14-2009, 01:14 AM
- By fred in forum New To JavaReplies: 1Last Post: 08-07-2007, 06:06 PM