Concerns about the function of JPanel: paintcomponent()

前端 未结 3 388
长发绾君心
长发绾君心 2020-11-28 07:49

hello I\'m new in java programming, and i need someone explaining me these lines of code:

 public class drawpanel extends JPanel
 {
     public void paintCom         


        
3条回答
  •  温柔的废话
    2020-11-28 08:07

    You only need to define paintComponent() in your class if you want to change the way your component if being drawn. In your custom implementation you need to call super.paintComponent(g); i.e. a base class version of paintComponent(), because it does some necessary work to prepare component for drawing.

提交回复
热议问题