Reposition a window and bring to the front?

2

I have created a window that shows a loading animation that says "Loading next data" .

My idea is that when the client presses a certain button the window appears with an animation while loading a record and then disappears.
The fact is that I want the window to appear in the middle of the screen and I am not capable. I have tried with the setRect and moveTo methods and although they place the window where I want to show it to me behind the layout, so it is not visible.
If I do not use setRect or moveTo the window looks good but at the top left of the screen.

The question is whether I'm using methods that are not for repositioning the screen, if there is any method to bring the screen to the front or if I'm not doing things in the order that I should.

EDIT: Writing the question I just realized after calling animateShow () what I do is put load a new layout, possibly covering the window , so what I need is a way to bring the window to the front .

EDIT2: Clarify that this is the window I'm talking about com.smartgwt .client.widgets.window

public class Test extends Window{

    private AnimationEffect animacionEntrada;
    private AnimationEffect animacionSalida;

    public Test(){
        setHeight                (125);
        setWidth                 (300);
        setAnimateTime           (300);
        setVisibility            (Visibility.HIDDEN);
        setIsModal               (false);

        HLayout layout = new HLayout();
        layout.setHeight100();
        layout.setWidth100();
        layout.setBackgroundColor("#dfe8f6");

        //Creo otros elementos... no muestro el código
        addItem(layout);

        animacionEntrada = AnimationEffect.FLY;
        animacionSalida  = AnimationEffect.FADE;

        //Intento reposicionar la ventana en el medio
        int alturaNavegador = com.google.gwt.user.client.Window.getClientHeight();
        int y = (alturaNavegador/2) - (getHeight()/2);

        setRect(50, y, getWidth(), getHeight());
    }

    public void mostrar(){
        animateShow(animacionEntrada, new AnimationCallback() {
            @Override
            public void execute(boolean earlyFinish){
                Timer t = new Timer(){
                    @Override
                    public void run(){
                        animateHide(animacionSalida);
                    }
                };
                t.schedule(1250);
            }
        });
    }
}
    
asked by Daniel Faro 07.07.2016 в 09:00
source

0 answers