Override JPanel parent frame

I want my panel to fit the frame when I show / hide the margins. How can I notify the parent frame for confirmation?

I thought about passing the frame to the panel constructor, but I think maybe that's already done. I remember there was a protected attribute in the JPanel, but no. I may remember the wrong component.

+2


a source to share


3 answers


I need to show / hide some of the fields of my panel and I want the panel to match the frame.

Do you mean as a summary / detail view and you want to resize the frame? Then try:



SwingUtilities.windowForComponent (...) package () ;.

+3


a source


you can override addNotify

in the panel:

public void addNotify() {
    getParent().revalidate();
    repaint();
    super.addNotify();
}

      



Not sure what that means.

+1


a source


SwingUtilities.getRoot(this).invalidate();

      

+1


a source







All Articles