Hello everyone,

Can anybody tell me how can i pass parameters to a paint method ? I know we can paint on a panel but can anyone provide a good example?
Something like this?
I know its wrong but please correct me.

int x=10;
int y=120;
JPanel p = new JPanel( 
public void Paint(Graphics g) {
g.drawString("hello its on panel",x,y);
}

Cheers

You don't need to pass parameters, just use class level variables (like you did in your example). Override the paintComponent method and use those class variables to control what gets painted.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.