2011-07-08 39 views
0

我該如何設置LWUIT中的按鈕位置?button lWUIT j2me setlocation

public void error() 
    { 
     error = new Dialog(); 
     e = new Label("EMPTY FIELDS!!!"); 
     t= new TextArea("You Can't Leave The Fields Empty...",8,13); 
     error.addComponent(e); 
     error.addComponent(t); 
     eok = new Button("Ok"); 
     eok.setAlignment(Component.CENTER); 
     eok.addActionListener(this); 
     error.addComponent(eok); 
     error.show(); 
    } 

回答

1

您需要使用佈局管理器。我猜你正試圖居中一個按鈕,而不是將它對齊到中心,只需將其添加到具有中心流佈局的容器即可:

Container c = new Container(new FlowLayout(Component.CENTER)); 
c.addComponent(btn);