about drawing a Polygon in java

前端 未结 3 705
生来不讨喜
生来不讨喜 2020-12-06 18:20

hi there i\'m trying to improve myself about java2D and first of all i\'m dealing with drawing polygons. However, i can not see the polygon on frame. I read some tutorials a

3条回答
  •  醉酒成梦
    2020-12-06 18:39

    JFrame does not extend JComponent so does not override paintComponent. You can check this by adding the @Override annotation.

    To get this functionality extract paintComponent to a new class which extends JComponent. Don't forget to call super.paintComponent(g) rather than super.paintComponents(g).

提交回复
热议问题