java之按钮美化
1. 设置⽆边框
button.setBorderPainted(false);
2. 设置背景透明
button.setBorderPainted(false);
3. 设置图标(按照按钮的⼤⼩进⾏缩放并且不显⽰⽂字,可以对按钮进⾏响应)
public static JButton changeIconSize(JButton button,String url,int width,int height,String btnstr){
button.setBounds(0,0,width,height);//设置按钮的界限
ImageIcon buttonImg=new ImageIcon(url);
//改变图⽚的⼤⼩
Image Image().Width(), Height(), Image().SCALE_DEFAULT);        button =new JButton(new ImageIcon(temp));
//设置按钮的点击时按钮字符串
button.setActionCommand(btnstr);
return button;
}
4. 去焦
button.setFocusPainted(false);
去焦前按下按钮
改变button按钮的形状去焦后按下按钮