How to repaint a child window?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ValValVal
    New Member
    • Oct 2008
    • 27

    How to repaint a child window?

    Hi.
    Please help me and sorry for my dumb question.

    I use NetBeans 6.1 in development.
    I have JFrame Client. In that JFrame when I click on button StartGame there appears another JFrame ChessGame. It has some Swing controls and some painting.Painti ng is done directly on JFrame. I am not sure,but probably this is called child window.

    Now I want this child window to be repainted well. I set event listeners on all possible relevant events that Swing gives me -WindowOpened,Wi ndowDeiconified ,WindowActivate d,WindowDeactiv ated in all of which I included call to update(this.get Graphics()). It seems like it hasn't helped one bit.Before I added this code ChessGame window was sometimes repainted and sometimes not when deiconifing.The same is true after I added the code.
  • JosAH
    Recognized Expert MVP
    • Mar 2007
    • 11453

    #2
    There should be no reason to explicitly repaint any component when the JFrame is deiconified or made visible; the AWT event thread takes care of that. What you do have to make sure is that you add your components to the content pane of the JFrame (read the API documentation of the JFrame class). It is an additional layer not present in the AWT Frame class.

    Normally I add a single JPanel to that content pane and use that for all my painting operations.

    kind regards,

    Jos

    Comment

    Working...