lwuit
  1. lwuit
  2. LWUIT-467

Strange Layout - scrollbar size wrong, List Elements not shown - fixed by BoxLayout.Y_AXIS

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Invalid
    • Affects Version/s: current
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None

      Description

      Hello all,

      this code looks really strange some List Elements are not displayed, only their line number is there,
      the scrollbar size is way to long.

      This gets fixed if I uncommented the line // searchForm.setLayout(new BoxLayout(BoxLayout.Y_AXIS));

      What gives?

      import java.io.IOException;
      import java.util.Vector;

      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.TextField;
      import com.sun.lwuit.geom.Dimension;
      import com.sun.lwuit.layouts.BorderLayout;
      import com.sun.lwuit.layouts.BoxLayout;
      import com.sun.lwuit.layouts.FlowLayout;
      import com.sun.lwuit.list.DefaultListModel;
      import com.sun.lwuit.plaf.UIManager;
      import com.sun.lwuit.util.Resources;

      public class Bug extends javax.microedition.midlet.MIDlet {

      DefaultListModel searchList = new DefaultListModel();
      static Vector sortedKeywords = new Vector();

      public void startApp() {
      sortedKeywords.addElement("a");
      sortedKeywords.addElement("b");
      sortedKeywords.addElement("c");
      sortedKeywords.addElement("d");
      sortedKeywords.addElement("e");
      sortedKeywords.addElement("f");
      sortedKeywords.addElement("g");
      sortedKeywords.addElement("h");
      sortedKeywords.addElement("i");
      sortedKeywords.addElement("j");
      sortedKeywords.addElement("k");
      sortedKeywords.addElement("l");
      sortedKeywords.addElement("m");
      sortedKeywords.addElement("n");
      sortedKeywords.addElement("a");
      sortedKeywords.addElement("b");
      sortedKeywords.addElement("c");
      sortedKeywords.addElement("d");
      sortedKeywords.addElement("e");
      sortedKeywords.addElement("f");
      sortedKeywords.addElement("g");
      sortedKeywords.addElement("h");
      sortedKeywords.addElement("i");
      sortedKeywords.addElement("j");
      sortedKeywords.addElement("k");
      sortedKeywords.addElement("l");
      sortedKeywords.addElement("m");
      sortedKeywords.addElement("n");
      sortedKeywords.addElement("a");
      sortedKeywords.addElement("b");
      sortedKeywords.addElement("c");
      sortedKeywords.addElement("d");
      sortedKeywords.addElement("e");
      sortedKeywords.addElement("f");
      sortedKeywords.addElement("g");
      sortedKeywords.addElement("h");
      sortedKeywords.addElement("i");
      sortedKeywords.addElement("j");
      sortedKeywords.addElement("k");
      sortedKeywords.addElement("l");
      sortedKeywords.addElement("m");
      sortedKeywords.addElement("n");

      Display.init(this);
      Form searchForm = new Form();
      final TextField searchArea = new TextField();
      searchForm.addComponent(searchArea);
      //searchList.removeAll();
      for (int i = 0; i < sortedKeywords.size(); i++)

      { String s = (String) sortedKeywords.elementAt(i); searchList.addItem(s); }

      System.out.println(sortedKeywords.size());
      final List searchL = new List(searchList);
      searchForm.addComponent(searchL);

      Label l = new Label(Integer.toString(searchL.size()));
      searchForm.addComponent(l);

      // with BoxLayout.Y everything is fine!
      // searchForm.setLayout(new BoxLayout(BoxLayout.Y_AXIS));

      searchForm.show();
      }

      public void pauseApp() {
      }

      public void destroyApp(boolean unconditional) {
      }
      }

        Activity

        Hide
        vprise added a comment -

        FlowLayout, the default layout in LWUIT. Works great for simple components and not for dynamically re-sizable components such as lists. It sucks at calculating their actual sizes hence the long scroll, this was explained quite often in the LWUIT forum and in the issue tracker. It can't be fixed properly without incurring a tremendous performance penalty.
        The list text doesn't disappear, the list calculates its preferred size based on the first 5 elements by default, once you pass the 10'th element the numbering makes the content too wide. By setting searchL.setListSizeCalculationSampleCount(100) you would slow LWUIT's performance but the characters won't disappear in this particular edge case.
        Use pretty much any other layout in LWUIT except Flow layout for dynamic components (dynamic components being: List, TextArea & multi-line text field).

        Show
        vprise added a comment - FlowLayout, the default layout in LWUIT. Works great for simple components and not for dynamically re-sizable components such as lists. It sucks at calculating their actual sizes hence the long scroll, this was explained quite often in the LWUIT forum and in the issue tracker. It can't be fixed properly without incurring a tremendous performance penalty. The list text doesn't disappear, the list calculates its preferred size based on the first 5 elements by default, once you pass the 10'th element the numbering makes the content too wide. By setting searchL.setListSizeCalculationSampleCount(100) you would slow LWUIT's performance but the characters won't disappear in this particular edge case. Use pretty much any other layout in LWUIT except Flow layout for dynamic components (dynamic components being: List, TextArea & multi-line text field).

          People

          • Assignee:
            Unassigned
            Reporter:
            cond
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: