可以更改JButton的形状吗? [英] Possible to change the shape of JButton?

查看:59
本文介绍了可以更改JButton的形状吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以将JButton的形状从矩形更改为圆形?

Is it possible to change the shape of JButton from rectangular to say round?

推荐答案

Sean Cogan提供的链接就是您所需要的.如果要简短,请设置图像(圆形或您希望按钮看起来类似的任何形状) 使用setIcon,然后在JButton(button1)上设置这些值-

Link provided by Sean Cogan is all you need. If you want it in short ,set an image (rounded or any shape that you want your button should look alike) using setIcon and then on the JButton (button1) set these values -

button1.setContentAreaFilled(false);
button1.setFocusPainted(false);
button1.setBorderPainted(false);

这篇关于可以更改JButton的形状吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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