Skip to main content

Accessing the frame variable through DefaultHelpBroker

1 reply [Last post]
Anonymous

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?

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

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:
> 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.