You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@pivot.apache.org by Bill van Melle <bi...@gmail.com> on 2010/12/18 02:46:49 UTC
how to get handle on main window?
Is there a way to get a handle on the top-level window that started an app?
E.g., deep in my application somewhere I want to open a dialog, and have a
way to pass it the proper window argument.
(Yes, I could save it at startup as a static in my top-level window class.
Just wondering if there was a more official way.)
Re: how to get handle on main window?
Posted by Greg Brown <gk...@verizon.net>.
> 1. That returns a java.awt.Window, not org.apache.pivot.wtk.Window, so is not suitable for passing to Sheet#open. I guess I asked the question wrong -- I want a handle on the org.apache.pivot.wtk.Window that I opened at startup. Or does that make sense? The whole hosting-window thing I still find a bit unnatural. I guess I could do getDisplay().get(0) and cast it to a Window.
You can call Component#getWindow() to get the top-level Pivot window.
> 2. What if I'm not inside the code of a pivot component when I want access to the top-level window?
You'll either need to maintain a reference to the window somewhere, or maintain a reference to a component that is attached to the window.
G
Re: how to get handle on main window?
Posted by Bill van Melle <bi...@gmail.com>.
1. That returns a java.awt.Window, not org.apache.pivot.wtk.Window, so is
not suitable for passing to Sheet#open. I guess I asked the question wrong
-- I want a handle on the org.apache.pivot.wtk.Window that I opened at
startup. Or does that make sense? The whole hosting-window thing I still
find a bit unnatural. I guess I could do getDisplay().get(0) and cast it to
a Window.
2. What if I'm not inside the code of a pivot component when I want access
to the top-level window?
Re: how to get handle on main window?
Posted by Greg Brown <gk...@verizon.net>.
There is. You can call component.getDisplay().getHostWindow(). That will return the AWT host frame.
On Dec 17, 2010, at 8:46 PM, Bill van Melle wrote:
> Is there a way to get a handle on the top-level window that started an app? E.g., deep in my application somewhere I want to open a dialog, and have a way to pass it the proper window argument.
>
> (Yes, I could save it at startup as a static in my top-level window class. Just wondering if there was a more official way.)