2012-01-19 3 views
1

저는 LWUIT을 사용하여 J2ME 응용 프로그램을 만듭니다. 컨트롤을 추가하기 위해 GridLayout을 사용했지만 정렬되지 않았습니다.LWUIT의 UI 정렬?

코드 : 사전에

flowLayout = new FlowLayout(); 
     roundsPage.setLayout(flowLayout); 


    try { 
     image = image.createImage("/11.png"); // All image 40 x 40 
     starImage = Image.createImage("/j1.png"); 
     smileImage = Image.createImage("/j2.png"); 
     imgClock = Image.createImage("/clock.jpg"); 
     imageTeam = Image.createImage("/name.png");   

    } catch (IOException e) { 
     // TODO Auto-generated catch block 
     e.printStackTrace(); 
    }   

    dateLabel=new Label("14-02-2012, Round1   "); 
    dateLabel.getStyle().setBgColor(0x8b8989); 
    dateLabel.getStyle().setFgColor(0xffffff); 
    roundsPage.addComponent(dateLabel); 

    //int screenWidth = Display.getInstance().getDisplayWidth(); 

    Container tabContainer1 = new Container(new BoxLayout(BoxLayout.Y_AXIS)); 
     tabContainer1.addComponent(new Button("Click")); 
     tabContainer1.addComponent(new Button("Click")); 
     tabContainer1.addComponent(new Button("Click")); 
     tabContainer1.addComponent(new Button("Click"));   


    Container tabContainer2 = new Container(new BoxLayout(BoxLayout.X_AXIS)); 
     team1=new Label(starImage); 
     team1.setText("Villarreal"); 
     team1.setTextPosition(Component.BOTTOM); 
     //team1.setWidth(10); 
     //team1.getStyle().setFont(Font.createSystemFont(Font.FACE_SYSTEM, Font.STYLE_PLAIN ,Font.SIZE_SMALL)); 
     tabContainer2.addComponent(team1); 
     tabContainer2.setWidth(100); 

     clockLabel=new Label(imgClock); 
     clockLabel.setText("18:00"); 
     clockLabel.setTextPosition(Component.RIGHT);    
     tabContainer2.addComponent(clockLabel); 

     teamLabel=new Label(imageTeam); 
     teamLabel.setText("El Madrigal"); 
     teamLabel.setTextPosition(Component.RIGHT); 
     tabContainer2.addComponent(teamLabel); 

     team2=new Label(smileImage); 
     team2.setText("Betis"); 
     team2.setTextPosition(Component.BOTTOM); 
     team2.setFocusable(true); 
     tabContainer2.addComponent(team2); 

    Container tabContainer3 = new Container(new BoxLayout(BoxLayout.Y_AXIS));   
     tabContainer3.addComponent(new Button("Click")); 
     tabContainer3.addComponent(new Button("Click")); 
     tabContainer3.addComponent(new Button("Click")); 
     tabContainer3.addComponent(new Button("Click"));   

    TabbedPane tabbbed = new TabbedPane(); 
    tabbbed.addTab(null, image, tabContainer1); 
    tabbbed.addTab(null, image, tabContainer2); 
    tabbbed.addTab(null, image, tabContainer3); 
    roundsPage.addComponent(tabbbed); 

감사합니다.

답변

0

"14-02-2012, Round1 "과 같이 사용하지 마십시오. 디스플레이의 너비를 가져오고 preferredW를 dateLabel에 설정하십시오. 화면 너비를 높이려면이 값을 사용하십시오.

int width = Display.getInstance().getDisplayWidth();

TabbedPane도 사용하지 마십시오. Tabs을 사용하십시오. addTab에 단추를 추가하고 단추의 너비를 설정하십시오. TabbedPane을 사용할 때 각 탭의 너비와 높이가 같기 때문입니다. 그게 문제 야.

+2

아래로 투표 한 이유가 무엇인가요? : -/ – bharath

+0

나는 투표를하지 않았다? 레이블과 이미지에 너비를 적용하는 방법. 내가 사용했다 int width = Display.getInstance(). getDisplayWidth(); dateLabel.setWidth (width); – selladurai

+0

'Label'에 setPreferredW (...)를 사용하십시오. 이미지를'Button'으로 설정하고 원하는대로 preferredW를 설정하십시오. – bharath