W
Wolfgang
I have been using a JPanel with a graphics object to draw lines, etc.,
like this:
private class DrawingPanel extends JPanel {
public void paint(Graphics g) {
x = 10; y = 20;
g.drawString("someText", x, y);
// draw all my graphics here...
// which means all calculation of coordinate
// locations x and y has to go here.
// I DON'T LIKE THAT, it causes clutter..
}
}
The above way of drawing is somewhat alien to me. I think of drawing
more like calculating some positions, than passing them to a drawing
method in a drawing object (something like a DrawingPanel). Java's
design of the Graphics class seems to disallow my preference, or I
cannot see a way to perform my simple "classical" way of drawing,
since I cannot pass coordinate locations for drawing into
DrawingPanel.paint.
Am I overlooking somthing simple here? If so, how can you do this?
Thanks,
Wolfgang
like this:
private class DrawingPanel extends JPanel {
public void paint(Graphics g) {
x = 10; y = 20;
g.drawString("someText", x, y);
// draw all my graphics here...
// which means all calculation of coordinate
// locations x and y has to go here.
// I DON'T LIKE THAT, it causes clutter..
}
}
The above way of drawing is somewhat alien to me. I think of drawing
more like calculating some positions, than passing them to a drawing
method in a drawing object (something like a DrawingPanel). Java's
design of the Graphics class seems to disallow my preference, or I
cannot see a way to perform my simple "classical" way of drawing,
since I cannot pass coordinate locations for drawing into
DrawingPanel.paint.
Am I overlooking somthing simple here? If so, how can you do this?
Thanks,
Wolfgang