This week's book giveaway is in the General Computing forum. We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line! See this thread for details.
for(int i = 0; i < 130; i++) { x++; y++; drawpanel.repaint();
try { Thread.sleep(20);//will know the meaning later }catch (Exception ex){ } } }
class MyDrawpanel extends JPanel//an inner class ( nested class) { public void paintCompnent(Graphics g) { g.setColor(Color.white); g.fillRect(0,0,this.getWidth(),this.getHeight());//will replace the green with white g.setColor(Color.green); g.fillOval(x,y,40,90); } }
Have you tried debugging your code? Put some println() statements in the paint method to see when/if it is called. Also if you are using java 1.6 look at using the @Override annotation.
sivasubramanian nagarajan
Greenhorn
Joined: Aug 07, 2008
Posts: 11
posted
0
hi friennd,
just checked with a print statement inside the paintComponent() method and it did not print that either.can you help me with the problem..
Hint: you don't have a "paintComponent()" method. Norm's suggestion to use the "@Override" annotation is directly related to this (and it works in 1.5, too, not just 1.6.)
Finally it worked.....paintComponent() method does exist...i had done a silly mistake of writing the paintComponent() incorrectly as paintCompnent()....