Search…
Sliding Window

Overview

Sliding Window is a fullscreen window that slides in and out of the screen during pop and unpop events. Use it to create transition effects between screens.

Source Code

SlidingWindow class
Calling the SlidingWindow
1
package com.totalcross;
2
3
import totalcross.ui.Container;
4
import totalcross.ui.Presenter;
5
import totalcross.ui.SlidingWindow;
6
7
public class MySlidingWindow extends SlidingWindow {
8
9
public MySlidingWindow(boolean delayInitUI, Presenter<Container> provider) {
10
super(delayInitUI, provider);
11
}
12
13
public MySlidingWindow(Presenter<Container> provider, int animDir,
14
int totalTime){
15
super(provider);
16
this.animDir = animDir; // This can be LEFT or RIGHT, any other will
17
// be BOTTOM
18
this.totalTime = totalTime; // Time, in milliseconds for the animation
19
}
20
}
Copied!
1
MySlidingWindow slidingWindow = new MySlidingWindow(new Presenter<Container>(){
2
3
@Override
4
public Container getView() {
5
return new Container() {
6
public void initUI() {
7
ImageControl i;
8
try {
9
i = new ImageControl(new Image("images/logoV.png"));
10
i.scaleToFit = true;
11
i.centerImage = true;
12
add(i, CENTER, CENTER, 100 + DP, 100 + DP);
13
} catch (IOException e) {
14
e.printStackTrace();
15
} catch (ImageException e) {
16
e.printStackTrace();
17
}
18
};
19
};
20
}
21
}, RIGHT, 500);
22
slidingWindow.popup();
Copied!
Because it is a more complex example, we only show the specific Sliding Window example code, if you want to see the whole code of the image interface construction click here.

Methods

Type
Name
Description
Constructor
SlidingWindow(Presenter<Container> provider)
Creates a SlidingWindow with the specified provider. Use the provider class to implement your view code.
Constructor
SlidingWindow(Presenter<Container> provider, boolean delayInitUI)
Creates a SlidingWindow with the specified provider and if it should delay the InitUI execution. Use the delayed InitUI if your screen takes a significant amount of time to load (e.g., it fetches data from a server) and the non-delayed InitUI if it is fast enough to be loaded prior to the animation. If the delayed option is used, the screen will popup with a spinner.
void
unpop( )
Unpops the SlidingWindow, hiding it.
void
popup( )
Popups the SlidingWindow, showing it.
Last modified 1yr ago