1
    import com.sun.lwuit.Button;
    import com.sun.lwuit.Command;
    import com.sun.lwuit.Display;
    import com.sun.lwuit.Label;
    import com.sun.lwuit.events.ActionEvent;
    import com.sun.lwuit.events.ActionListener;
    import com.sun.lwuit.layouts.BorderLayout;
    import com.sun.lwuit.plaf.UIManager;
    import com.sun.lwuit.util.Resources;
    import java.io.IOException;


    public class Ruwwa extends javax.microedition.midlet.MIDlet implements ActionListener{

    Form f;
    Button mybutton1;
    Button mybutton2;
    Command exit;
    Command ok;


    public void startApp() {

           Display.init(this);

           f = new Form();

           try {

           Resources r = Resources.open("/mairuwa.res");
           UIManager.getInstance().setThemeProps(r.getTheme("Mairuwa Theme"));

           } catch (IOException ioe) {
             ioe.printStackTrace();
           }

           mybutton1=new Button("Report A Problem");
           mybutton2=new Button("Request Info");

           f.setLayout(new BorderLayout());
           f.addComponent(BorderLayout.CENTER, new Label("The Mairuwa Portal"));

           ok = new Command("OK");
           exit = new Command("Exit");

           f.addCommand(ok);
           f.addCommand(exit);
           f.addCommandListener(this);

           f.show();

           }

    public void pauseApp() {}

    public void destroyApp(boolean unconditional) {}

    public void actionPerformed(ActionEvent ae) {
       notifyDestroyed();
    }

}

「メールワ ポータル」の下にもう 1 つラベルを追加し、その下にも 2 つのボタン (「問題を報告」、「情報をリクエスト」) を配置したいと思います。私が説明していることの実例は

label:                          The Mairuwa Portal
then another label beneath it:  I want to:

次に、この Button:Report Problem Button: Request Information の下にある 2 つのボタン

プロジェクトにOKボタンとEXITボタンを追加できましたが、上記のボタンについては、説明したとおりにする必要があります。

これらのボタンには機能があります。これがLWUITでできることを願っています。

4

1 に答える 1

1

シンプルです。BoxLayout.Y_AXISforを使用してForm、ラベルをフォームに追加します。ContainerBoxLayout.Y_AXIS(またはx_AXIS、必要に応じて)を作成し、これにボタンを追加してContainer、の余白を設定しContainerます。やり方はサンプルコードを見て、

Form form = new Form("form");
form.setLayout(new BoxLayout(BoxLayout.Y_AXIS));
Label label1 = new Label("Label 1");
Label label2 = new Label("Label 2");
form.addComponent(label1);
form.addComponent(label2);
Container c = new Container(new BoxLayout(BoxLayout.X_AXIS));
int center = Display.getInstance().getDisplayWidth()/2;
c.getStyle().setMargin(0, 0, center , 0);    
Button b1 = new Button("button 1");
Button b2 = new Button("button 2");
c.addComponent(b1);
c.addComponent(b2);
form.addComponent(c);
form.show();
于 2011-11-22T11:17:01.367 に答える