Java 如何使用LWUIT将列表居中对齐

Java 如何使用LWUIT将列表居中对齐,java,java-me,lwuit,Java,Java Me,Lwuit,我无法将列表项对齐到中心。请帮帮我。这是我已经完成的代码 import com.sun.lwuit.Command; import com.sun.lwuit.Component; import com.sun.lwuit.Display; import com.sun.lwuit.Form; import com.sun.lwuit.Image; import com.sun.lwuit.Label; import com.sun.lwuit.List; import com.sun.lwu

我无法将列表项对齐到中心。请帮帮我。这是我已经完成的代码

import com.sun.lwuit.Command;
import com.sun.lwuit.Component;
import com.sun.lwuit.Display;
import com.sun.lwuit.Form;
import com.sun.lwuit.Image;
import com.sun.lwuit.Label;

import com.sun.lwuit.List;
import com.sun.lwuit.events.ActionEvent;
import com.sun.lwuit.events.ActionListener;
import com.sun.lwuit.layouts.BoxLayout;
import javax.microedition.midlet.MIDlet;


/**
 * @author Administrator
 */
public class main extends MIDlet implements ActionListener
{
  private Image logo;
  private Label logoLabel;
  private List menu;
  private Command select,exit;        

  public void startApp() {
    Display.init(this);
    Form form1 =new Form();
    form1.getStyle().setBgColor(0xe5a812);
    try{
        logo=Image.createImage("/sid_logo.png");
    }
    catch(Exception e){
        System.out.println("::::::"+e);
    }
    logoLabel=new Label(logo);
    select=new Command("Select");
    exit=new Command("Exit");

    //form1.setLayout(new BorderLayout());        
    //form1.addComponent(BorderLayout.NORTH,logoLabel);
    BoxLayout boxlayout=new BoxLayout(BoxLayout.Y_AXIS);
    form1.setLayout(boxlayout);
    form1.addComponent(logoLabel);
    logoLabel.setAlignment(Component.CENTER);
    logoLabel.getStyle().setBgColor(0xe5a812);
    menu=new List();
    menu.addItem("LIST 1");
    menu.addItem("LIST 2");
    form1.addComponent(menu);
    form1.addCommand(select);
    form1.addCommand(exit);
    form1.setCommandListener(this);
    form1.show();

  }

  public void pauseApp() {
  }

  public void destroyApp(boolean unconditional) {
  }
  public void actionPerformed(ActionEvent event){
    //int index=menu.getSelectedIndex();
    if(event.getCommand()==select && menu.getSelectedIndex()==0){
        System.out.println("Check list1");


    }
    if(event.getCommand()==select && menu.getSelectedIndex()==1){
        System.out.println("Check list 2");
    }
    if(event.getCommand()==exit){
        notifyDestroyed();
    }
  }

}
使用将类扩展到
Label
中,并实现
ListCellRenderer
接口。并将
标签
对齐设置为
居中

供参考:使用并开发自己的主题