Wednesday, July 7, 2010

LWUIT: BorderLayout

LWUIT: BorderLayout


import javax.microedition.midlet.*;
import com.sun.lwuit.*;
import com.sun.lwuit.events.*;
import com.sun.lwuit.layouts.BorderLayout;

public class LwuitLayout extends MIDlet implements ActionListener {
public void startApp() {
Display.init(this);
Form f = new Form("Hello, MIDlet in LWUIT!");
Command exitCommand = new Command("Exit");
f.addCommand(exitCommand);
f.setCommandListener(this);

BorderLayout borderLayout = new BorderLayout();
f.setLayout(borderLayout);
f.setTitle("BorderLayout");

Label labelCenter = new Label("Center");
Label labelEast = new Label("East");
Label labelSouth = new Label("South");
Label labelWest = new Label("West");
Label labelNorth = new Label("North");
f.addComponent(BorderLayout.CENTER, labelCenter);
f.addComponent(BorderLayout.EAST, labelEast);
f.addComponent(BorderLayout.SOUTH, labelSouth);
f.addComponent(BorderLayout.WEST, labelWest);
f.addComponent(BorderLayout.NORTH, labelNorth);

f.show();
}

public void pauseApp() {}
public void destroyApp(boolean unconditional) {}
public void actionPerformed(ActionEvent ae) {
notifyDestroyed();
}
}