0

是否可以创建一个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();
}   
4

0 回答 0