是否可以创建一个JComponent
类,其中paintComponent()
可以在另一个类中实例化,并且可以调用自己的repaint()
方法?
class A extends JComponent {
@Override
paintComponent(){//code here
}
}
class B {
static public A temp = new A();
void someMethod() {
if (something)
temp.repaint(); //will this repaint this particular
//component if it was in a JFRAME
else if (something)
//do not repaint
else if (anothersomething)
temp.repaint();
}