关于JButton的UI设置
我自定义了一个JButton的UI类,继承BasicButtonUI类,重载了其中的installDefaults方法,在该方法中,设置了我自定义的background和border。
界面上的按钮虽然使用了我的backgound和border,但是当我点击按钮时,没有了JButton原来有的按下的动画效果,也就是说,我画面上的JButton当按下时外观没有改变。
不知道我的意思有没有表达清楚。
:)
下面是我的代码:
public class FBNBookButtonUI extends BasicButtonUI{
protected void installDefaults(AbstractButton b) {
//super.installDefaults(b);
// *** begin optimized defaults install ***
Color currentBackground = b.getBackground();
Border currentBorder = b.getBorder();
if (currentBackground == null || currentBackground instanceof UIResource) {
b.setBackground(ArtuSwingConstants.buttonBackground);
}
if (currentBorder == null || currentBorder instanceof UIResource) {
b.setBorder(ArtuSwingConstants.buttonBorder);
}
// *** end optimized defaults install ***/
}
...
}
请Swing高手指点一下:
如何才能使我画面上的按钮具有动画效果?