Results 1 to 3 of 3
Thread: JPanel motion
- 03-08-2011, 09:22 AM #1Member
- Join Date
- Mar 2011
- Rep Power
I'm working on a simple aplication where is an JFrame, and 2 JPanels on it.
I would like to write an simple motion with these JPanels. I implemented a simple version, but there is some flickering on the screen. How could I solve it?
Here is my code:
Jpanel c3 = new JPanel();
Graphics g = this.getGraphics();
c3.setLocation(130 + i, 30);
this.update(g); //this is currently the JFrame.update
Please help me...
You seem to be doing graphics wrong including calling getGraphics on a component. I suggest that you read the Graphics tutorials and see how to do graphics correctly and your problems will correct themselves. If you want to move a component, then use a null layout, a Swing Timer and change it's location in the Timer. Again the tutorials will help.
- 03-08-2011, 05:42 PM #3
- By batyuska87 in forum AWT / SwingReplies: 0Last Post: 03-06-2011, 09:17 AM
- By Thomask in forum Java AppletsReplies: 8Last Post: 02-17-2011, 05:23 PM
- By MarkWilson in forum Advanced JavaReplies: 4Last Post: 12-07-2009, 06:45 AM
- By Atriamax in forum Java AppletsReplies: 5Last Post: 09-17-2009, 06:06 AM
- By ixhabbaba in forum Java AppletsReplies: 2Last Post: 11-11-2007, 08:53 PM