如何在Java中重新绘制()组件

时间:2013-10-28 18:09:04

标签: java swing

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

0 个答案:

没有答案