Hi,
i have start to try out lwuit.
I have build 3 screens. When ein push a button cmdSlide, i want show the 2. screen for a certain time (2 sec) and slide without to push a button to the 3. screen.
But with this code it is not possible. With Thread.sleep(2000) 2 sec wait on the 1. screen, not on the 2. screen. The 2 sec comes everytime with the button-event.
Anyone an idea how i could solve this delay problem to get a delay on the 2. screen.
Thx
import java.io.IOException;
import javax.microedition.midlet.MIDlet;
import javax.microedition.midlet.MIDletStateChangeException;
import com.sun.lwuit.Button;
import com.sun.lwuit.Command;
import com.sun.lwuit.Container;
import com.sun.lwuit.Display;
import com.sun.lwuit.Form;
import com.sun.lwuit.Label;
import com.sun.lwuit.animations.CommonTransitions;
import com.sun.lwuit.animations.Transition3D;
import com.sun.lwuit.events.ActionEvent;
import com.sun.lwuit.events.ActionListener;
import com.sun.lwuit.layouts.BorderLayout;
import com.sun.lwuit.layouts.BoxLayout;
import com.sun.lwuit.plaf.UIManager;
import com.sun.lwuit.util.Resources;
public class BasicForm extends MIDlet implements ActionListener {
private Form form1;
private Form form2;
private Form form3;
//private Command cmdRotate = new Command("Rotate");
private Command cmdSlide = new Command("Slide");
private Command cmdSlide2 = new Command("Slide2");
private Command cmdSlide3 = new Command("Slide3");
private Command cmdExit = new Command("Exit");
public BasicForm() {
//Initialize the LWUIT
Display.init(this);
}
protected void startApp() throws MIDletStateChangeException {
//Load the Theme
Resources r;
try {
r = Resources.open("/LWUITtheme.res");
UIManager.getInstance().
setThemeProps(r.getTheme("LWUITDefault"));
} catch (IOException e) {
e.printStackTrace();
}
form1 = new Form("Form 1");
form1.setLayout(new BoxLayout(BoxLayout.Y_AXIS));
form1.addComponent(0,null,new Label("This is the first Form"));
form1.addCommand(cmdSlide);
form1.addCommand(cmdExit);
form1.addCommandListener(this);
form1.setTransitionInAnimator(CommonTransitions.createSlide(CommonTransitions.SLIDE_HORIZONTAL, false, 1000));
//Setup Form 2
form2 = new Form("Form 2");
form2.setLayout(new BoxLayout(BoxLayout.Y_AXIS));
form2.addComponent(0,null,new Label("This is the second Form"));
//form2.addCommand(cmdSlide2);
//form2.addCommand(cmdExit);
form2.addCommandListener(this);
form2.setTransitionInAnimator(CommonTransitions.createSlide(CommonTransitions.SLIDE_HORIZONTAL, false, 1000));
form3 = new Form("Form 3");
form3.setLayout(new BoxLayout(BoxLayout.Y_AXIS));
form3.addComponent(0,null,new Label("This is the third Form"));
form3.addCommand(cmdSlide3);
form3.addCommand(cmdExit);
form3.addCommandListener(this);
form3.setTransitionInAnimator(CommonTransitions.createSlide(CommonTransitions.SLIDE_HORIZONTAL, false, 1000));
form1.show();
}
public void actionPerformed(ActionEvent evt) {
//check which command cliked
if (evt.getCommand()==cmdExit) {
notifyDestroyed();
} else if (evt.getCommand()==cmdSlide) {
form2.show();
try {
Thread.sleep(2500);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
form3.show();
}else if (evt.getCommand()==cmdSlide3) {
form1.show();
}
}
protected void destroyApp(boolean unconditional) throws MIDletStateChangeException {
}
protected void pauseApp() {
}
}

Reply With Quote

