學(xué)用Java

          奇新Java控件---Java控件提供商和Java RIA, Web, J2ME解決方案開(kāi)發(fā)商

          介紹JComponentPack產(chǎn)品中的JListView控件


          If you want to implements the Windows explorer like feature in Java swing application, the JListView component meets your requirements exactly.

          The JListView component support the 5 different view modes: small icon, large icon, list, thumbnails, details, all these view mode can change on the fly, the methods “JListView.setViewMode” can change the view mode of JListView component.

          The JListView component have the MVC design concept, a simple TableModel can be provided for it’s data, a simple CellProvider such IconProvider can be provided for it’s icon. Should write a DefaultCellRenderer subclass for its renderer and DefaultCellEditor subclass for it’s editor. The article “Introduce Cell Renderer” introduce why using the DefaultCellRenderer.

          The JListView component use a ListSelectionModel as it’s selection model, you can change the selection model’s mode, it support single selection, single interval selection, multiple interval selection, you can use the following methods to get the selected values:

                JListView.getSelectedValue(); // get the lead selection value
                 JListView.getSelectedValues(); // get all selected values

          The JListView component provides several methods for it’s editing:
                 JListView.isEditing(); // determines whether the JListView is being edited.
                 JListView.cancelEditing(); // cancel current editing
                 JListView.stopEditing(); // stop the current editing and apply the editing value
                 JListView.startEditingAtIndex(); // start the editing at the specified index
                 JListview.getEditingInex(); // get the current editing object’s index

          The com.zfqjava.swing.model and com.zfqjava.swing.cell package have the FileTableModel and FileProvider, it support the directory list and file icon directly, the following code can create a explorer like GUI:

                 JListView listView = new JListView();
                 listView.setListData(new FileTableModel(new File(System.getProperty("user.home"))));
                 listView.setCellRenderer(new FileCellRenderer());
                 listView.setCellEditor(new FileCellEditor());

          The JListView component also support row sorting, the TableModel you provided for JListView only need implements the ColumnSorter interface, it can support the row sorting automatically, we want to improve this area after upgrade the JRE version to 1.6.

          The JListView component provides several important client property:

          JListView.rowSelectionAllowed” allow the full row can be selected
          JListView.showVerticalLines” shows the vertical lines in details view mode.
          JListView.showHorizontalLines” shows the horizontal lines in details view mode.
          JListView.backgroundImage” sets the background image for JListView component.

          For details, you can view the JListView JavaDoc API documentation.

          The JListView also support the Drag and Drop, but in JComponentPack 1.1.0 and early version, implements this feature has trick and tips:

                 // get JTable and JList
                 BasicListViewUI ui = (BasicListViewUI)listView.getUI();
                 JTable table = ui.getTable();
                 JList list = ui.getList();
                 table.setDragEnabled(true);
                 list.setDragEnabled(true);
                 TransferHandler th = new TransferHandler() {             
                        public int getSourceActions(JComponent c) {
                         return COPY;
                  }
                        protected Transferable createTransferable(JComponent c) {
                            // just a test
                            Object o = listView.getSelectedValue();
                            if(o != null) {
                               return new StringSelection(o.toString());
                            }
                            return null;
                        }
                     };
                 table.setTransferHandler(th);
                 list.setTransferHandler(th);

          In the upcoming version JComponentPack 1.2.0, we have improved this area, so in the new version, implements the drag and drop feature is very simple:

                 listView.setDragEnabled(true);
          TransferHandler th = new TransferHandler() {
                        public int getSourceActions(JComponent c) {
                         return COPY;
                  }

                        protected Transferable createTransferable(JComponent c) {
                            // just a test
                            Object o = listView.getSelectedValue();
                            if(o != null) {
                               return new StringSelection(o.toString());
                            }
                            return null;
                        }
                     };
                 listView. setTransferHandler(th);


          If you want to implements the Windows explorer like feature in Java swing application, the JListView component meets your requirements exactly.

          The JListView component support the 5 different view modes: small icon, large icon, list, thumbnails, details, all these view mode can change on the fly, the methods “JListView.setViewMode” can change the view mode of JListView component.

          The JListView component have the MVC design concept, a simple TableModel can be provided for it’s data, a simple CellProvider such IconProvider can be provided for it’s icon. Should write a DefaultCellRenderer subclass for its renderer and DefaultCellEditor subclass for it’s editor. The article “Introduce Cell Renderer” introduce why using the DefaultCellRenderer.

          The JListView component use a ListSelectionModel as it’s selection model, you can change the selection model’s mode, it support single selection, single interval selection, multiple interval selection, you can use the following methods to get the selected values:

                JListView.getSelectedValue(); // get the lead selection value
                 JListView.getSelectedValues(); // get all selected values

          The JListView component provides several methods for it’s editing:
                 JListView.isEditing(); // determines whether the JListView is being edited.
                 JListView.cancelEditing(); // cancel current editing
                 JListView.stopEditing(); // stop the current editing and apply the editing value
                 JListView.startEditingAtIndex(); // start the editing at the specified index
                 JListview.getEditingInex(); // get the current editing object’s index

          The com.zfqjava.swing.model and com.zfqjava.swing.cell package have the FileTableModel and FileProvider, it support the directory list and file icon directly, the following code can create a explorer like GUI:

                 JListView listView = new JListView();
                 listView.setListData(new FileTableModel(new File(System.getProperty("user.home"))));
                 listView.setCellRenderer(new FileCellRenderer());
                 listView.setCellEditor(new FileCellEditor());

          The JListView component also support row sorting, the TableModel you provided for JListView only need implements the ColumnSorter interface, it can support the row sorting automatically, we want to improve this area after upgrade the JRE version to 1.6.

          The JListView component provides several important client property:

          JListView.rowSelectionAllowed” allow the full row can be selected
          JListView.showVerticalLines” shows the vertical lines in details view mode.
          JListView.showHorizontalLines” shows the horizontal lines in details view mode.
          JListView.backgroundImage” sets the background image for JListView component.

          For details, you can view the JListView JavaDoc API documentation.

          The JListView also support the Drag and Drop, but in JComponentPack 1.1.0 and early version, implements this feature has trick and tips:

                 // get JTable and JList
                 BasicListViewUI ui = (BasicListViewUI)listView.getUI();
                 JTable table = ui.getTable();
                 JList list = ui.getList();
                 table.setDragEnabled(true);
                 list.setDragEnabled(true);
                 TransferHandler th = new TransferHandler() {             
                        public int getSourceActions(JComponent c) {
                         return COPY;
                  }
                        protected Transferable createTransferable(JComponent c) {
                            // just a test
                            Object o = listView.getSelectedValue();
                            if(o != null) {
                               return new StringSelection(o.toString());
                            }
                            return null;
                        }
                     };
                 table.setTransferHandler(th);
                 list.setTransferHandler(th);

          In the upcoming version JComponentPack 1.2.0, we have improved this area, so in the new version, implements the drag and drop feature is very simple:

                 listView.setDragEnabled(true);
          TransferHandler th = new TransferHandler() {
                        public int getSourceActions(JComponent c) {
                         return COPY;
                  }

                        protected Transferable createTransferable(JComponent c) {
                            // just a test
                            Object o = listView.getSelectedValue();
                            if(o != null) {
                               return new StringSelection(o.toString());
                            }
                            return null;
                        }
                     };
                 listView. setTransferHandler(th);



          posted on 2009-02-25 10:56 fralepg 閱讀(530) 評(píng)論(0)  編輯  收藏


          只有注冊(cè)用戶(hù)登錄后才能發(fā)表評(píng)論。


          網(wǎng)站導(dǎo)航:
           
          <2009年2月>
          25262728293031
          1234567
          891011121314
          15161718192021
          22232425262728
          1234567

          導(dǎo)航

          統(tǒng)計(jì)

          公告

          JComponentPack 3.0正式發(fā)布 功能介紹

          JComponentPack 是一個(gè)基于Java SwingGUI類(lèi)庫(kù),一系列可視化的JavaBeans集合,它基于SwingMVC架構(gòu),是100%的純Java類(lèi)庫(kù),它包括20多個(gè)Swing 所沒(méi)有的控件

          試用版下載(點(diǎn)擊下載

          常用鏈接

          留言簿(1)

          隨筆檔案

          文章檔案

          搜索

          最新評(píng)論

          閱讀排行榜

          評(píng)論排行榜

          主站蜘蛛池模板: 营山县| 海晏县| 新余市| 弥勒县| 汕头市| 彭州市| 南阳市| 安国市| 莆田市| 江津市| 丰镇市| 嫩江县| 郧西县| 安龙县| 习水县| 新津县| 大关县| 红安县| 九寨沟县| 扶沟县| 兴宁市| 太湖县| 肃宁县| 北碚区| 郸城县| 许昌市| 淮安市| 黑水县| 鄂尔多斯市| 通城县| 马边| 武冈市| 汽车| 炎陵县| 绥阳县| 西乌| 辉南县| 汤阴县| 乡城县| 托里县| 报价|