Java 肮脏的富客户端-ObjectModifier中的propertySetter存在问题
我试图使用框架中的Animator类,在我的JFrame中,我做到了:Java 肮脏的富客户端-ObjectModifier中的propertySetter存在问题,java,Java,我试图使用框架中的Animator类,在我的JFrame中,我做到了: @Override public void mouseClicked(MouseEvent e) { super.mouseClicked(e); Animator animator = new Animator(100); animator.addTarget(new PropertySetter(AnimatedIcon.this, "alpha", 0.0f)); animator.se
@Override
public void mouseClicked(MouseEvent e) {
super.mouseClicked(e);
Animator animator = new Animator(100);
animator.addTarget(new PropertySetter(AnimatedIcon.this, "alpha", 0.0f));
animator.setAcceleration(0.2f);
animator.setDeceleration(0.4f);
animator.start();
}
});
但结果我得到了以下错误:
ObjectModifier中的propertySetter存在问题
调用setValue中的方法时出现问题:java.lang.NullPointerException
请帮忙,我尝试了很多方法来解决它,但都没有成功。
AnimatedIcon是一个外部类这个怎么样
super.mouseClicked(e);
PropertySetter setter = new PropertySetter(AnimatedIcon.this, "alpha", 0.0f));
Animator animator = new Animator(100, setter);
animator.setAcceleration(0.2f);
animator.setDeceleration(0.4f);
animator.start();
谢谢大家,我发现了我的错误:这个类没有声明为public,而是默认的。由于我正在使用使用注释的框架,并且该框架不是来自同一个包,所以非公共类不允许从外部使用其方法 你有一个额外的};在您的示例代码中。哪一行引发此异常?animator.start;抛出异常。它不是作为例外打印的,而是作为一个简单的系统。。。;所以没有堆栈可供查看。Animator是您的类吗?你有它的代码吗?没有,动画师是框架的类,来自计时框架。由Romain Guy通过阅读PropertySetter类的源代码开发,看起来您缺少了setAlpha。。从动画片课上。你能确认你在那个类中有那个API吗?