The size is 0 because the window has not been laid out yet. Can you perform 
your logic based on the preferred size of the window? That is generally the 
size it will be given when layout occurs.

On Dec 4, 2011, at 7:02 AM, Piotr Kołaczkowski <[email protected]> 
wrote:

> Hi,
> 
> How to get the size of a window or frame?
> Should be trivial - just use getSize or getWidth or getHeight. Actually it is 
> not :(
> 
> class MainWindow extends Window {
> 
>   void openSubFrame() {
>      Frame frame = .... // load frame from BXML or whatever
>      int width = frame.getWidth();   // returns 0
>      frame.open(this);
>      width = frame.getWidth();  // still 0
>   }
> }
> 
> 
> After some time, when the frame is rendered on the screen, the getWidth 
> returns the actual width.
> So, how to get the size of the frame before it is displayed? I want to apply 
> some custom positioning of frames and I have to know their size.
> 
> Regards,
> Piotr
> 
> 
> -- 
> Piotr Kołaczkowski
> senior consultant
> Sages Sp. z o.o.
> ul. Wąwozowa 11
> 02-796 Warszawa
> t: +48 22 2035600
> f: +48 22 2035601
> m: +48 609618449
> 

Reply via email to