Reputation: 95
I have a JFrame
and a class extending JPanel
and overriding paintComponent()
(named DrawingPanel
). An instance of DrawingPanel
is added to the JFrame
.
This is the paintComponent()
method of DrawingPanel
:
public void paintComponent(Graphics g){
super.paintComponent(g);
Graphics2D g2d = (Graphics2D) g;
Rectangle rect = new Rectangle(80,180,50,50);
g2d.fill(rect);
}
I ran the program, and it seems that the coordinats 80, 180 specified when creating rect
, refer to the JFrame
that contains the instance of DrawingPanel
. I would expect that these coordinates would refer to the JPanel
where the rectangle is actually painted.
1) Is it supposed to be like that?
2) Is it possible to change this?
Thanks
Upvotes: 0
Views: 49