Paint background of JPanel

前端 未结 5 688
盖世英雄少女心
盖世英雄少女心 2021-01-19 05:16

How can I tell the paint method to draw background on JPanel only and not on the entire JFrame. My JFrame size is bigger than the JPanel. When I try to paint a grid backgrou

5条回答
  •  南方客
    南方客 (楼主)
    2021-01-19 05:44

    You should override the JPanel, not the JFrame to do painting. You can override the paintComponent() method of the JPanel

提交回复
热议问题