Skip to main content

setDisplayed() --> IllegalArgumentException: null owner window

2 replies [Last post]
magic.finger
Offline
Joined: 2006-02-17
Points: 0

Hello,

I run into problems when calling DefaultHelpBroker.setDisplayed() at first from a JDialog (via a button with applied enableHelpOnButton()) and after that from JMenuItem ActionListener:

The exception message under jre 1.4.1_02 and jh v2.0._01 is:
java.lang.IllegalArgumentException: null owner window
at java.awt.Window.ownedInit(Window.java:364)
at java.awt.Window.(Window.java:324)
at java.awt.Dialog.(Dialog.java:313)
at javax.swing.JDialog.(JDialog.java:324)
at javax.swing.JDialog.(JDialog.java:302)
at javax.help.WindowPresentation.createHelpWindow(WindowPresentation.java:737)
at javax.help.WindowPresentation.setDisplayed(WindowPresentation.java:336)
at javax.help.DefaultHelpBroker.setDisplayed(DefaultHelpBroker.java:178)
at de.mycompany.mypackage.MyHelp.dynaHelpBrokerSetDisplayed(MyHelp.java:725)
at de.mycompany.mypackage.MyHelp.showHelp(MyHelp.java:99)
...

Is there any workaround or bug fix available ?

Thanx in advance for any hints and tips !

Maik

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Roger Brinkley

java-help@JAVADESKTOP.ORG wrote:
> Hello,
>
> I run into problems when calling DefaultHelpBroker.setDisplayed() at first from a JDialog (via a button with applied enableHelpOnButton()) and after that from JMenuItem ActionListener:
>
> The exception message under jre 1.4.1_02 and jh v2.0._01 is:
> java.lang.IllegalArgumentException: null owner window
> at java.awt.Window.ownedInit(Window.java:364)
> at java.awt.Window.(Window.java:324)
> at java.awt.Dialog.(Dialog.java:313)
> at javax.swing.JDialog.(JDialog.java:324)
> at javax.swing.JDialog.(JDialog.java:302)
> at javax.help.WindowPresentation.createHelpWindow(WindowPresentation.java:737)
> at javax.help.WindowPresentation.setDisplayed(WindowPresentation.java:336)
> at javax.help.DefaultHelpBroker.setDisplayed(DefaultHelpBroker.java:178)
> at de.mycompany.mypackage.MyHelp.dynaHelpBrokerSetDisplayed(MyHelp.java:725)
> at de.mycompany.mypackage.MyHelp.showHelp(MyHelp.java:99)
> ...
>
> Is there any workaround or bug fix available ?

My guess is that you don't have an owner for the JDialog. Howerver, the
bug appears to be in the JDK and not in javahelp.

Binky

********************************************************************************

You may leave the list at any time by sending message with no subject and
"SIGNOFF JAVAHELP-INTEREST" in the body to LISTSERV@JAVA.SUN.COM. Archives
are available at http://archives.java.sun.com/archives/javahelp-interest.html.
Submit bug reports at http://java.sun.com/cgi-bin/bugreport.cgi.

magic.finger
Offline
Joined: 2006-02-17
Points: 0

Hi Binky,

thanks a lot for your answer, but I have provided owner frame to constructor of my override class for JDialog as follows:
public class MyDialog extends JDialog {
public MyDialog(JFrame mainFrame) {
super(mainFrame, true);
hb.enableHelpKey(this, "foo", hs);
setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
...
}
}
After trying out some workarounds to avoid the null owner window exception I succeed after introducing the method override processWindowEvent() to the dialog class MyDialog.
Since the processWindowEvent() method is always called before windowClosing() WindowListener, which I previously used to capture closing event, now the processWindowEvent() method captures WINDOW_CLOSING event first and calls hide() method of JDialog as last action.
So, the windowClosing() method is not called anymore. And exactly this leads to the fact, that the null owner window exception is also not thrown anymore.

Maybe the owner window handle is (automatically) set to null by Java when windowClosing() method is called ?
I have no idea. Anyway I have a solution right now :-)

Here is the code snippet:
-----------------------------------------
public class MyDialog extends JDialog {

public MyDialog(JFrame mainFrame) {
super(mainFrame, true);
hb.enableHelpKey(this, "foo", hs);
setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
...
}

protected void processWindowEvent(WindowEvent e) {
// just handle WINDOW_CLOSING event at this point
// instead inside windowClosing listener, which
// is invoked after this method (avoids exception
// thrown by JavaHelp)
if (e.getID() == WindowEvent.WINDOW_CLOSING) {
hide();
}
else {
super.processWindowEvent(e);
}

}
-----------------------------------------

Lucky Maik