0

I know to minimize the jframe, I need to use setExtendedState(JFrame.ICONIFIED);
But what I am trying to figure out is how to get to the frame. This dialog is child of a parent dialog. Here is the Constructor.

    public EdiBaseDialog(EdiDialogHandler edh, Frame parent, TCSession theSession) {
      super(parent, false);
      session = theSession;
      createDialog();
   } 

So when I try to add setExtendedState(JFrame.ICONIFIED) command in my jbutton actionPerformed. Which is in a JPanel Method.

I do not know how to address the frame.

??.setState(JFrame.ICONFIED);
mKorbel
  • 109,525
  • 20
  • 134
  • 319
jkteater
  • 1,381
  • 3
  • 36
  • 69

2 Answers2

2

Call Dialog.getOwner() from within the dialog.

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
1

What you need to do is go up in the component hierarchy until you arrive at the Frame. There are already helper methods in Swing to do this. Try SwingUtilties:

SwingUtilities.getAncestorOfClass(JFrame.class, this);

(Where 'this' can be any component in the hierarchy) Of course this will only be of use if your dialogs are forming a proper hierarchy (no dialogs using a NULL owner. If thats the case, you have to pass in the Frame through some method or constructor.

Durandal
  • 19,919
  • 4
  • 36
  • 70