如何在java swing中设置按钮的背景图像 [英] How to set the background image of a button in java swing

查看:87
本文介绍了如何在java swing中设置按钮的背景图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在 Swing 中更改 JButton 的背景图像,
方法 :Button.setIcon(),
只设置图标不设置背景,有没有简单的方法来做到这一点?

I want to change the background image of a JButton in swing,
The method : Button.setIcon (),
Set’s the icon only not the background, Is there a easy way to do that?

推荐答案

使用 SynthLookAndFeel 的简单方法 here 或者您可以创建一个扩展 JButton 的类并提供paintComponent(Graphics g)的新实现

The easy way use SynthLookAndFeel as described here or you could go with creating a class that extends JButton and provide a new implementation of paintComponent(Graphics g)

这篇关于如何在java swing中设置按钮的背景图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆