Repaint Manager

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ragaman123
    New Member
    • Nov 2006
    • 13

    #1

    Repaint Manager

    Hello there,

    I am developing a game in java and for the options menu at the start i install a NullRepaintMana ger to override paint requests.
    I was wondering however how to later go back to not using this RepaintManger i.e disable this NullRepaintMang er and return to how repaint requests are normally handled?

    Any help or advice would be greatly appreciated,

    Cheers,

    Ragaman

    P.S The code for NullRepaintMana ger:

    public class NullRepaintMana ger extends RepaintManager {


    public static void install() {
    RepaintManager repaintManager = new NullRepaintMana ger();
    repaintManager. setDoubleBuffer ingEnabled(fals e);
    RepaintManager. setCurrentManag er(repaintManag er);
    }


    public void addInvalidCompo nent(JComponent c) {
    // do nothing
    }

    public void addDirtyRegion( JComponent c, int x, int y,
    int w, int h)
    {
    // do nothing
    }

    public void markCompletelyD irty(JComponent c) {
    // do nothing
    }

    public void paintDirtyRegio ns() {
    // do nothing
    }

    }


    I was wondering however how to later go back to not using this RepaintManger i.e disable this NullRepaintMang er and return to how repaint requests are normally handled?

    Any help or advice would be greatly appreciated,

    Cheers,

    Ragaman
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    Originally posted by ragaman123
    Hello there,

    I am developing a game in java and for the options menu at the start i install a NullRepaintMana ger to override paint requests.
    I was wondering however how to later go back to not using this RepaintManger i.e disable this NullRepaintMang er and return to how repaint requests are normally handled?

    Any help or advice would be greatly appreciated,

    Cheers,

    Ragaman

    P.S The code for NullRepaintMana ger:

    public class NullRepaintMana ger extends RepaintManager {


    public static void install() {
    RepaintManager repaintManager = new NullRepaintMana ger();
    repaintManager. setDoubleBuffer ingEnabled(fals e);
    RepaintManager. setCurrentManag er(repaintManag er);
    }


    public void addInvalidCompo nent(JComponent c) {
    // do nothing
    }

    public void addDirtyRegion( JComponent c, int x, int y,
    int w, int h)
    {
    // do nothing
    }

    public void markCompletelyD irty(JComponent c) {
    // do nothing
    }

    public void paintDirtyRegio ns() {
    // do nothing
    }

    }


    I was wondering however how to later go back to not using this RepaintManger i.e disable this NullRepaintMang er and return to how repaint requests are normally handled?

    Any help or advice would be greatly appreciated,

    Cheers,

    Ragaman
    1.)Next time please remember the code tags when posting code.
    2.)Why dont you create a new RepaintManager and set it using
    Code:
    RepaintManager.setCurrentManager(repaintManager);

    Comment

    • ragaman123
      New Member
      • Nov 2006
      • 13

      #3
      Thank you for the advice, how do i go about setting the original repaint manager?

      Comment

      • r035198x
        MVP
        • Sep 2006
        • 13225

        #4
        Originally posted by ragaman123
        Thank you for the advice, how do i go about setting the original repaint manager?
        How about

        Code:
         RepaintManager rM = new RepaintManager();
        then
        Code:
         [left]RepaintManager.setCurrentManager(rM);
        [/left]

        Comment

        Working...