zoukankan      html  css  js  c++  java
  • e782. 排列JList中的项

    By default, the items in a list are arranged vertically, in a single column, as in:

        item1
        item2
        ...
    

    It is possible to arrange the items left-to-right and top-to-bottom, as in:

        item1    item2
        item3    item4
        item5    ...
    

    This example creates and configures a list that displays its items left-to-right and top-to-bottom. Note that the number of columns can change as the width of the list changes.

        // Create a scrollable list
        String[] items = {"A", "B", "C", "D"};
        JList list = new JList(items);
        JScrollPane scrollingList = new JScrollPane(list);
        
        // The default layout orientation is JList.VERTICAL
        int orient = list.getLayoutOrientation();
        
        // Change the layout orientation to left-to-right, top-to-bottom
        list.setLayoutOrientation(JList.HORIZONTAL_WRAP);
    

    The items can also be arranged top-to-bottom and left-to-right, as in:

        item1    item4
        item2    item5
        item3    ...
    

    This example changes the layout orientation so that its items are displayed top-to-bottom and left-to-right.

        // Change orientation to top-to-bottom, left-to-right layout
        list.setLayoutOrientation(JList.VERTICAL_WRAP);
    

    With some look and feels, a list is set to display a fixed number of rows. In order to make the number of visible rows dependent on the height of the list, the visibleRowCount property must be set to 0:

        // Make the number of rows dynamic
        list.setVisibleRowCount(0);
    
    Related Examples
  • 相关阅读:
    c99柔性数组
    Android自定义XML属性以及遇到的命名空间的问题
    [翻译]API Guides
    使用线程实现视图平滑滚动
    [翻译]API Guides
    [翻译]API Guides
    [翻译]Android官方文档
    探究Android中通过继承ViewGroup自定义控件的原理
    初探Android动画之门
    ViewPager、Fragment、Matrix综合使用实现Tab滑页效果
  • 原文地址:https://www.cnblogs.com/borter/p/9596140.html
Copyright © 2011-2022 走看看