Skip to main content

RE: [JAVAHELP] Accessing the frame variable through DefaultHelpBroker

1 reply [Last post]
Anonymous

Good question!

Looks like he added a WindowListener when the frame was a dialog using 'windowClosed' and 'windowClosing'.

Also, he added an Escape key handler when the frame was an instance of JFrame. He also changed the icon for the JFrame and added a WindowListener as well. My guess is that he is overwriting the existing 'windowClosing' and 'windowClosed' for the JFrame.

So with 2.0_02 we can eliminate the help icon and move that to the .hs file. Any ideas on the others?

-----Original Message-----
From: Discussion list of JavaHelp [mailto:JAVAHELP-INTEREST@JAVA.SUN.COM] On Behalf Of Roger Brinkley
Sent: Wednesday, March 08, 2006 8:37 PM
To: JAVAHELP-INTEREST@JAVA.SUN.COM
Subject: Re: [JAVAHELP] Accessing the frame variable through DefaultHelpBroker

David Cagle wrote:
> Binky,
>
> In 1.1.3 it was pretty easy to access the 'protected JFrame frame'
> variable in DefaultHelpBroker. But in 2.0_02 that variable has been
> moved to WindowPresentation and made private. I have a developer (was
> using 1.1.3) who was accessing the 'frame' variable in a class which
> extended DefaultHelpBroker like this:
>
> public Frame getMainFrame() {
> super.initPresentation();
> Frame f = super.frame;
> if (f instanceof JFrame) {
> ...
> }
> return f;
> }
>
> Would you recommend updating the code to:
> public Frame getMainFrame() {
> super.initPresentation();
> Window window = getWindowPresentation().getHelpWindow();
> if (window instanceof JFrame) {
> ...
> }
> return (Frame)f;
> }
>
> This looks like it will do the same thing but wanted to make sure. I
> also read in a previous post that 'getHelpWindow()' may return null if
> the window has not been displayed yet, so he should add a check for that.
>
> Does all this look good to you?

The reason you don't want to use the frame is that it has a propensity to go away and come back under a variety of circumstances. That's one reason the access to the frame was depricated.

So the question to ask is what is that he needs the frame for. There is probably another way of doing (most likely by the help author).

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.

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

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.

Reply viewing options

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

David Cagle wrote:
> Good question!
>
> Looks like he added a WindowListener when the frame was a dialog
> using 'windowClosed' and 'windowClosing'.
>
> Also, he added an Escape key handler when the frame was an instance
> of JFrame. He also changed the icon for the JFrame and added a
> WindowListener as well. My guess is that he is overwriting the
> existing 'windowClosing' and 'windowClosed' for the JFrame.
>
> So with 2.0_02 we can eliminate the help icon and move that to the
> .hs file. Any ideas on the others?

Yeah but your not going to like them. One is to override the
DefaultHelpBroker and be aware of problems that were discussed
previously about the window changing. The other is to be your own
controller of the JFrame. In this case you're not going to use the
default helpbroker and would control all the displays yourself. It would
be like rewriting WindowPresentation and DefaultHelpbroker for your own
needs.

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.