2015-01-05 84 views
0

我想擺脫用BoxY佈局滾動容器的拉伸拖動。Codenameone拉伸拖動問題

代碼:

f.setScrollable(false); 

    appendExit(f); 
    String form_uuid = ""; 

    Container tlist = new Container(new BoxLayout(BoxLayout.Y_AXIS)); 
    tlist.setScrollableY(false); 
    tlist.setTensileDragEnabled(false); 
    Container tocCntn = new Container(new BoxLayout(BoxLayout.Y_AXIS)); 
    tlist.setUIID("toc"); 
    BorderLayout bl = new BorderLayout(); 
    bl.setCenterBehavior(BorderLayout.CENTER_BEHAVIOR_CENTER_ABSOLUTE); 
    Container tocH = new Container(bl); 

    Label lic = new Label(AppState.res.getImage("Menu_Icon.png")); 
    lic.setUIID("Container"); 
    lic.getStyle().setMargin(Component.LEFT, 10); 
    tocH.addComponent(BorderLayout.WEST, lic); 
    Label l_h = new Label("Contents"); 
    l_h.setUIID("typelabel"); 
    tocH.addComponent(BorderLayout.CENTER, l_h); 
    tlist.addComponent(tocH); 


    TopicParser parser = new TopicParser(); 
    switch (AppState.topic_type) { 
     case 1: 
      AppState.typelabel = "Listening Skills"; 
      form_uuid = "lbg"; 
      AppState.icon = AppState.res.getImage("licon.png"); 
      brandface = AppState.res.getImage("list_girl.png"); 
      AppState.current_topics = parser.parse(AppState.l_topics); 
      tocH.setUIID("ltoc"); 
      break; 
     case 2: 
      AppState.typelabel = "Speaking Skills"; 
      form_uuid = "rbg"; 
      brandface = AppState.res.getImage("speak_girl.png"); 
      AppState.icon = AppState.res.getImage("sicon.png"); 
      AppState.current_topics = parser.parse(AppState.s_topics); 
      tocH.setUIID("stoc"); 
      break; 
     case 3: 
      AppState.typelabel = "Reading Skills"; 
      form_uuid = "rbg"; 
      AppState.icon = AppState.res.getImage("ricon.png"); 
      brandface = AppState.res.getImage("reading_boy.png"); 
      AppState.current_topics = parser.parse(AppState.r_topics); 
      tocH.setUIID("rtoc"); 
      break; 
     case 4: 
      AppState.typelabel = "Writing Skills"; 
      form_uuid = "rbg"; 
      brandface = AppState.res.getImage("writing_girl.png"); 
      AppState.icon = AppState.res.getImage("wicon.png"); 
      AppState.current_topics = parser.parse(AppState.w_topics); 
      tocH.setUIID("wtoc"); 
      break; 
    } 
    int i = 0; 
    for (final Topic topic : AppState.current_topics) { 
     i++; 
     Container topicC = new Container(new BoxLayout(BoxLayout.Y_AXIS)); 
     //topicC.setUIID("wbg"); 
     if (topic.getTopic_name().trim().equals("")) { 
      Label l = new Label(" ");     
      l.setUIID("toclbl"); 
      topicC.addComponent(l); 
     } else { 
      Button topicB = new Button(i + ". " + topic.getTopic_name()); 
      topicB.addActionListener(new ActionListener() { 
       public void actionPerformed(ActionEvent evt) { 
        AppState.current_topic = topic; 
        showForm("player", null); 
       } 
      }); 
      topicB.setUIID("toclbl"); 
      topicC.addComponent(topicB); 
     } 


     tocCntn.addComponent(topicC); 
    } 
    tocCntn.setScrollableY(true);   
    tocCntn.setScrollVisible(false); 
    tocCntn.setTensileDragEnabled(false); 
    tlist.addComponent(tocCntn); 
    f.addComponent(BorderLayout.CENTER, tlist); 
    findTypename(f).setText(AppState.typelabel); 
    findTypeiconimg(f).setIcon(AppState.icon); 
    f.setGlassPane(new Painter() { 

     public void paint(Graphics g, Rectangle rect) { 
      g.drawImage(brandface, f.getLayoutWidth()-brandface.getWidth(), f.getLayoutHeight()-brandface.getHeight()-findTopicFooter(f).getLayoutHeight()); 
     } 
    }); 

但是它似乎沒有工作。

  1. 有沒有其他辦法可以做到這一點?
  2. 有沒有辦法來改變滾動條

enter image description here

回答

1

setTensileDragEnabled應該做的伎倆的顏色,我認爲你所看到的窗體本身的拉伸阻力而不是你的tocCntn集裝箱。

試試這個:

Form f = new Form(); 
f.setLayout(new BorderLayout()); 
f.setScrollable(false); 
Container cnt = new Container(new BoxLayout(BoxLayout.Y_AXIS)); 
cnt.setScrollableY(true); 
cnt.setTensileDragEnabled(false); 
//add Components to the cnt Container 
... 
f.addComponent(BorderLayout.CENTER, cnt); 
f.show(); 
+0

沒有工作。用整個代碼更新我的問題。我有一個包含兩個容器(Y)的表單,其中一個表單可滾動 – sanket

+0

同樣發現includeNativeBool = false時這不起作用。有沒有解決方法? – sanket

0
UIManager.getInstance().getLookAndFeel().setDefaultTensileDrag(false); 

的伎倆