怎么在Java里添加背景图片

怎么在Java里添加背景图片,第1张

可以新建面板,在面板里放入带图片的JLabel,填满面板即可。

JPanel jp = new JPanel()//新建面板

jp.setLayout(new FlowLayout()) //设置面板布局

ImageIcon ii=new ImageIcon(getClass().getResource("/Picture/i.jpg"))

JLabel uppicture=new JLabel(ii)//往面板里加入JLabel

this.setVisible(true)

可以新建个面板,在面板里放入带图片的JLabel,填满面板即可。

JPanel jp = new JPanel()//新建面板

jp.setLayout(new FlowLayout())//设置面板布局

ImageIcon ii=new ImageIcon(getClass().getResource("/Picture/i.jpg"))

JLabel uppicture=new JLabel(ii)//往面板里加入JLabel

this.setVisible(true)


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/bake/8020336.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-04-12
下一篇 2023-04-12

发表评论

登录后才能评论

评论列表(0条)

保存