java - How do I get paintComponent(Graphics g) to call? repaint() won't work every time -


the following in java se6 program tic tac toe game:

i have class minipanel extends jpanel have in grid. if user clicks 1 of these, listener stuff then... eventually, calls method placex() or placeo() on minipanel clicked. stuff prints out message saying method called, , next line calls animatepanel() method, calls repaint() inside, printing out message right before.

the class minipanel overrides paintcomponent(graphics g) method first prints out message saying paintcomponent called super.paintcomponent(g) , other stuff.

the problem when click minipanel, first 2 messages saying placex() or placeo() , animatepanel() called appears, means repaint() must have been called. paintcomponent(graphics g) never called! weird thing works if call placex() directly when minipanel initialized not otherwise.

i have paintcomponent(graphics g) overridden, nothing else.

here paintcomponent:

public void paintcomponent(graphics g){         if (controller.debug) system.out.println("minipanel @ ("+row+", "+col+") received paintcomponent (is repainting now).");         super.paintcomponent(g);         ...         ...     } 

placex (placeo pretty same thing):

    public void placex(){     ...     if (controller.debug) system.out.println("minipanel @ ("+row+", "+col+") received placex.");     ...     animatepanel(); } 

animatepanel:

        private void animatepanel() {     if (controller.debug) system.out.println("minipanel @ ("+row+", "+col+") doing animatepanel().");     timer.start(); } 

the timer calls repeatedly little animation:

        private actionlistener taskperformer = new actionlistener() {     public void actionperformed(actionevent evt) {         if (controller.debug) system.out.println("minipanel @ ("+row+", "+col+") doing actionperformed().");         ...         if (controller.debug) system.out.println("minipanel @ ("+row+", "+col+") repaint... should receive paintcomponent command!");         repaint();     } }; 


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -