about drawing a Polygon in java

前端 未结 3 704
生来不讨喜
生来不讨喜 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:50

    Replace

    protected void paintComponent(Graphics g){
    
        super.paintComponents(g);
    
        g.setColor(Color.BLUE);
        g.drawPolygon(poly);
    
    }   
    

    With

    protected void paint(Graphics g){
    
        super.paint(g);
    
        g.setColor(Color.BLUE);
        g.drawPolygon(poly);
    
    }  
    

提交回复
热议问题