我构建了一个看起来像这样的JHoverButton类:
package javabeanslab;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class JHoverButton extends JButton implements MouseListener {
public JHoverButton(){
super();
initialize();
}
public JHoverButton(String text){
super(text);
initialize();
}
public JHoverButton(String text, Icon icon){
super(text, icon);
initialize();
}
public void setEnabled(boolean enabled){
super.setEnabled(enabled);
if(enabled){
if(isBorderPainted()){
setBorderPainted(false);
repaint();
}
}
}
private void initialize(){
setBorderPainted(false);
addMouseListener(this);
}
@Override
public void mouseClicked(MouseEvent me) {
}
@Override
public void mousePressed(MouseEvent me) {
}
@Override
public void mouseReleased(MouseEvent me) {
}
@Override
public void mouseEntered(MouseEvent me) {
if(!isBorderPainted() && isEnabled()){
setBorderPainted(true);
repaint();
}
}
@Override
public void mouseExited(MouseEvent me) {
if(isBorderPainted()){
setBorderPainted(false);
repaint();
}
}
}
现在,当我访问Netbeans中的GUI构建器时,我点击"选择Bean"然后我将路径声明为javabeanslab.JHoverButton以将按钮添加到GUI中但是我弹出这个错误:
我做错了什么?
答案 0 :(得分:0)
问题是,要在GUI Builder中使用类,必须已经编译它,因为该工具会查找.class
文件来加载窗口小部件的属性。