PDA

Click to See Complete Forum and Search --> : manually calling paint


nabeels786
Mar 26th, 2002, 10:47 AM
how do i pass it "Graphics g"?

nabeels786
Mar 26th, 2002, 11:33 AM
nvermind, got it

paint(getGraphics());

crptcblade
Mar 26th, 2002, 06:38 PM
From what I know, paint() is a callback, and should only be called directly by the system (not that it really makes a difference), you should just call the repaint() method.

:)

nabeels786
Mar 28th, 2002, 01:36 PM
repaint didn't work for some reason.

calling paint() did it, sort of. now i overrode the paint() function itself so no more flickering :)

CaptainPinko
Apr 1st, 2002, 01:33 AM
Originally posted by crptcblade
From what I know, paint() is a callback, and should only be called directly by the system (not that it really makes a difference), you should just call the repaint() method.

:)

could you plz tell me more about the repaint() method? i 've never got it to work... PLZ!:confused:

Dillinger4
Apr 2nd, 2002, 12:59 AM
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

public class RedDewDrop{
public static void main(String[] args){
new Circle();
}
}
class Circle extends Canvas{

public Circle(){

JFrame jf = new JFrame("DewDrop");
jf.addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e){
System.exit(0);
}
});

Dimension size = jf.getSize();
Insets i = jf.getInsets();
int height = size.height - i.top - i.bottom;
int width = size.width - i.left - i.right;

this.setSize(height,width);
jf.getContentPane().add(this);
jf.setSize(400,300);
jf.setVisible(true);
}

public void paint(Graphics g){
g.setColor(Color.red);
for(int i = 0; i < 100; i++){
g.fillOval(50,50,i,i);
try{
Thread.sleep(100);
}catch(Exception e){System.err.println(e);}
}
}
}