Skip to main content

Newbie Question About Canvas class

1 reply [Last post]
flush
Offline
Joined: 2010-01-19
Points: 0

Is it possible to paint outside the " void paint ( Graphics g)" procedure ?

like this

protected void paint(Graphics g) {
drawoutside();
}

void drawoutside {}
g.drawLine(x1,y1,x2,y2);
}

How the heck a programmer must have all the paint commands inside in one procedure ?

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
iluminacja
Offline
Joined: 2010-01-08
Points: 0

You should invoke all methods in this function. You can write paint method in another function, but you have to get 'Graphics g' as parameter. For following code

protected void paint(Graphics g) {
drawoutside(g);
}

void drawoutside(Graphics g) {}
g.drawLine(x1,y1,x2,y2);
}

should work. There is no reason to try painting in other function.