You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@pivot.apache.org by JLEIngenieros <jl...@gmail.com> on 2013/12/24 01:50:25 UTC

Re: Getting proper size of the window component

Hello, Javier from Seville (Spain). It's my first post, and at first,
apologize for my english.

I understand that the post is quite old, but i think that this response can
help to other users:

Recently, I had the same problem, and I thought in a timer. Here is the
result:


        //notice: miPanel is an ImageViewer
        //notice: import java.util.Timer;import java.util.TimerTask;

        //Loading the image, via exception (null, etc.)
        try{
            miPanel.setImage("blah/blah../Sample.jpg");
        } catch(Exception ex) {
           
        } finally {
            //Waiting for finish loading
            //
            TimerTask timerTask = new TimerTask() {
                @Override
                public void run()
                {                    
                    System.out.println(miPanel.getParent().getWidth());
                           //Here you can write if...then, per sample:
                          if(miPanel.getParent().getWidth()!=0) {  
                                   timer.cancel();
                                   other methods...
                                   //This is only for ensure:
                                  
System.out.println(miPanel.getParent().getWidth());
                          }
                }
             };    

            // Here, the timer:
           Timer timer = new Timer();
           // in 0 milliseconds look at run each 1000 milliseconds
           timer.scheduleAtFixedRate(timerTask, 0, 1000);              

Hope this helps
Regards
Javier 



--
View this message in context: http://apache-pivot-users.399431.n3.nabble.com/Getting-proper-size-of-the-window-component-tp3558909p4022813.html
Sent from the Apache Pivot - Users mailing list archive at Nabble.com.