學用Java

          奇新Java控件---Java控件提供商和Java RIA, Web, J2ME解決方案開發商

          介紹JComponentPack產品中的單元格染色器和編輯器

          Introduce the cell renderer and editor in JComponentPack 1.1.0


          1. ObjectCellRenderer and it’s subclass such as DateCellRenderer, NumberCellRenderer is used by JDataGrid or JTable component, if you want to write a cell renderer for JDataGrid, you should extend ObjectCellRenderer.The ObjectCellEditor and it’s subclass is used by JDataGrid or JTable component.

          You can view these cell renderers in the com.zfqjava.swing.cell package before reinvent the wheel.
           The ObjectCellRenderer have the following subclass in com.zfqjava.swing.cell package:

          BigDecimalCellRenderer,
          BigIntegerCellRenderer,
          BooleanCellRenderer,
          DateCellRenderer,
          NumberCellRenderer,
          StreamCellRenderer,
          URLCellRenderer   
          The ObjectCellRenderer and ObjectCellEditor and it’s subclass are managed by CellManager object,
          The JDataGrid use the CellManger object to mange all it’s cell renderer and editor, so you can add the renderer and editor for CellManager, you can also remove or replace the cell renderer or editor in CellManger.

           Write a ObjectCellRenderer subclass is very simple, generally you only need override it’s “setValue(java.lang.Object value)”method.

           Writer a ObjectCellEditor subclass, you can override it’s three methods:

          protected  void  

           commitEdit()

          protected  Object  

          getValue()

          protected  void 

          setValue(Object value)

          If the editing have illegal value, you should override the “commitEdit()” method and throws a ParseException.
          You can use the method setValue(Object value) to save the edited value, and
          Override the method getValue() to return the new value.

          You can use the protected field “label” to set the text, alignment, font, etc.

          2. DefaultCellRenderer and it’s subclass such as FileCellRenderer is used by JListView component, DefaultCellEditor and it’s subclass such as FileCellEditor is used by JListView component, it works with the JListView component to provide the different view modes: small icon, large icon, list, thumbnails, details, so if you want to use JListView component, you can extend the DefaultCellRenderer.

          Write the DefaultCellRenderer and DefaultCellEditor is same as the ObjectCellRenderer and ObjectCellEditor, the different is you should use the protected field “iconLabel” and “textLabel” to set the icon and text.

          posted on 2009-02-24 09:46 fralepg 閱讀(346) 評論(0)  編輯  收藏


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


          網站導航:
           
          <2009年2月>
          25262728293031
          1234567
          891011121314
          15161718192021
          22232425262728
          1234567

          導航

          統計

          公告

          JComponentPack 3.0正式發布 功能介紹

          JComponentPack 是一個基于Java SwingGUI類庫,一系列可視化的JavaBeans集合,它基于SwingMVC架構,是100%的純Java類庫,它包括20多個Swing 所沒有的控件

          試用版下載(點擊下載

          常用鏈接

          留言簿(1)

          隨筆檔案

          文章檔案

          搜索

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 崇明县| 方山县| 阿拉尔市| 西峡县| 松原市| 富源县| 万荣县| 库车县| 平陆县| 福鼎市| 秦安县| 右玉县| 朔州市| 静乐县| 泽州县| 北安市| 云浮市| 新余市| 张家港市| 同江市| 金坛市| 霍州市| 斗六市| 榕江县| 景德镇市| SHOW| 茂名市| 海阳市| 尼勒克县| 张家界市| 馆陶县| 汕头市| 疏附县| 东山县| 宜川县| 化德县| 泰州市| 烟台市| 邹平县| 丹棱县| 大足县|