隨筆-50  評論-55  文章-8  trackbacks-0
          ?在使用java默認的lokandfeel的 時候,要想讓JTree不同的行顯示行高,只需要cellRenderer的組件設置大小就可以了,而換作windowlookandfeel的時候,不僅要設置組件大小,對樹還要設置 setRowHeight(0);
          請看如下解釋:
          The tree component's row height property controls the height of every displayed node. If the row height is greater than 0, all rows will be given the specified height. However, if the rows can be of differing heights, it is necessary to set the row height to 0. With a 0 row height, all heights of all rows are computed individually.
              // Create tree
              JTree tree = new JTree();
              
              // All rows will be given 15 pixels of height
              tree.setRowHeight(15);
              
              // Have the row height for each row computed individually
              tree.setRowHeight(0);
              
              // If the row height is 0 and the height of a row has dynamically changed, it is necessary
              // to flush the internal cache of row heights. The following calls flush the internal cache.
              if (tree.getRowHeight() <= 0) {
                  // Temporary change to non-zero height
                  tree.setRowHeight(1);
              }
              tree.setRowHeight(0);
          以上解釋來自:http://www.javaref.cn/egs/javax.swing.tree/RowHeight.html

          ?Related Examples
          posted on 2007-11-26 10:28 蔣家狂潮 閱讀(555) 評論(0)  編輯  收藏 所屬分類: Swing

          只有注冊用戶登錄后才能發表評論。


          網站導航:
          博客園   IT新聞   Chat2DB   C++博客   博問  
           
          主站蜘蛛池模板: 呈贡县| 时尚| 张家港市| 石首市| 淳安县| 青铜峡市| 德州市| 定襄县| 仙桃市| 屏东县| 凌源市| 汤阴县| 咸宁市| 南漳县| 濮阳市| 安福县| 京山县| 开化县| 睢宁县| 高雄市| 西宁市| 台山市| 通河县| 呈贡县| 富阳市| 开原市| 福贡县| 井冈山市| 克什克腾旗| 仪征市| 芦山县| 依安县| 丰都县| 乐东| 云霄县| 射洪县| 临夏县| 新昌县| 汝南县| 醴陵市| 祁阳县|