package newpackage;
import net.rim.device.api.system.Display;
import net.rim.device.api.ui.*;
import net.rim.device.api.ui.component.BasicEditField;
import net.rim.device.api.ui.component.ButtonField;
import net.rim.device.api.ui.component.LabelField;
import net.rim.device.api.ui.container.MainScreen;
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author Tiandi Zhang
*/
public class Demo extends UiApplication {
public static void main(String[] args){
Demo theApp = new Demo();
theApp.enterEventDispatcher();
}
public Demo(){
pushScreen(new mainscreen());
}
}
class mainscreen extends MainScreen{
public mainscreen() {
super();
LabelField title = new LabelField("TextField Demo",LabelField.ELLIPSIS|LabelField.USE_ALL_WIDTH);
setTitle(title);
BasicEditField t1 = new BasicEditField("Text",""){
public int getPreferredWidth()
{
return Display.getWidth();
}
public int getPreferredHeight()
{
return 100;
}
public void layout(int width, int height)
{
super.layout(width, getPreferredHeight());
setExtent(width, getPreferredHeight());
}
};
ButtonField b1 = new ButtonField("save");
add(t1);
add(b1);
}
}
BasicEditField的layout
最新推荐文章于 2021-03-17 00:41:33 发布