Re: appFrame
masukomi <[email protected]>
| Newsgroups | gmane.comp.embedded.carlsbad-cubes |
|---|---|
| Message-ID | <[email protected]> |
ok I missed a crucial bit before...
public static void setAppFrame(Frame frame) {
if (frame != null) {
if (SwingEngine.appFrame == null) {
SwingEngine.appFrame = frame;
}
}
}
I didn't realize that setAppFrame wasn't a simple assignment. Made the
mistake of assuming that since all the other getters and setters were
it would be too
but.... I'm still unsure if the isAssignableFrom test is the best test
for the job. It will work but... hmm... maybe that is the best
solution.
-Kate
On May 11, 2004, at 10:21 PM, masukomi wrote:
> There's a little piece of code in SwingEngine that either I'm not
> understanding right or is flawed.
>
> just before render(Document) completes it does this
>
> if (Frame.class.isAssignableFrom(root.getClass())) {
> SwingEngine.setAppFrame((Frame) root);
> }
>
> Now, this piece of code raises two issues for me.
>
> I *think* what it's trying to do is find the ultimate parent frame of
> your app and set appFrame to be that. I think this because of this
>
> /** main frame */
> private static Frame appFrame;
>
> and
>
> /**
> * @return <code>Frame</code> a parent for all dialogs.
> */
> public static Frame getAppFrame() {
> return SwingEngine.appFrame;
> }
>
>
> The thing is I don't see how class.isAssignableFrom(Class) can
> possibly make that decision. Every time you call the render method in
> your SwingEngine instance and the root element is a JFrame it's going
> to say "ooh that's assignable...I'll make that the new appFrame" But
> what if the one in your original call to render was the one you
> actually wanted? I could see a List of root frames or something like
> that but making it a single one doesn't make any sense to me.
>
> Next up. Why is it static? Isn't this going to cause issues when you
> have multiple instances of SwingEngine running around?
>
> Given, I've never actually had to call getAppFrame() but if I did I
> think I'd be unhappy with the results. Wouldn't it make more sense to
> test if the root that was just rendered was higher up in the window
> hierarchy than the current root? Or, just set appFrame to whatever the
> root window was. I know there's a way to get that fairly directly I
> just can't remember it at the moment. If we did that then the static
> thing wouldn't be an issue I don't think.
>
> -Kate_______________________________________________
> Forum mailing list
> [email protected]
> http://carlsbadcubes.com/mailman/listinfo/forum_carlsbadcubes.com
_______________________________________________
Forum mailing list
[email protected]
http://carlsbadcubes.com/mailman/listinfo/forum_carlsbadcubes.com