问题描述
你好,我想自定义一个按钮,如下代码所示
public class CustomButton extends JToggleButton{
public CustomButton() {
}
public void paintComponent(Graphics g){
Color bg,text;
if(isSelected()){
bg = Color.decode("#000");
text = Color.decode("#fff");
}else{
bg = Color.decode("#fff");
text = Color.decode("#000");
}
setBackground(bg);
setForeground(text);
super.paintComponent(g);
}
}
我收到此错误 => 类型不兼容:CustomButton 无法转换为 jButton
jButton2 = new CustomButton();
你能说出问题出在哪里吗?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)