JPanel not showing background image

本小妞迷上赌 提交于 2019-12-01 22:50:26

Replace

public void printComponent(Graphics g) {

with

@Override
public void paintComponent(Graphics g) {
  super.paintComponent(g);

Don't use a JPanel. Just use a JLabel with an Icon then you don't need custom code.

See Background Panel for more information as well as a solution that will paint the image on a JPanel with 3 different painting options:

  1. scaled
  2. tiled
  3. actual
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!