2009年2月24日
JComponentPack 是一个基于Java Swing的GUI类库,一系列可视化的JavaBeans集合,它基于Swing的MVC架构,是100%的纯Java类库,它包括20多个Swing 所没有的控件,如EXCEL风格Java的电子表格控件,读取数据库表的Java表格控件,日历控件,类似资源管理器的列表控件,向导框架等等,这些 JavaBeans可以直接拖动到您的图形用户界面,它可提高您的工作效率,加快您的项目开发过程。
功能列表
· JBean应用程序框架
JBean应用程序框架提供了一个标准的Swing应用程序框架,它支持从属性文件创建Actions,创建和动态显示菜单,也支持创建单选按钮,多选按钮,能动态改变按钮状态。它提供了一个资源管理类,能够从定义好的资源文件装载小图标,菜单和按钮的资源。
JBean应用程序框架包含了一些常用的标准控件,包括打印和打印预览控件,状态栏控件,登陆对话框,反馈对话框,外观改变对话框等。
JBean应用程序框架包含了一些常用的单元格绘制和编辑器,它们支持通用的数据类型,包括数字,日期,文件,图表,颜色等类型。这些单元格绘制和编辑器也提供了不同的控件支持,包括复选框,下拉框等。
· JComponentSet控件集
JComponentSet是一个Java
swing控件集,包括JWizardPane,
JListView, Layout Suite (CellLayout, BoxLayout2, CardLayout2, GridLayout2), JDirChooser,
JCalendar, JFontChooser, JLinkButton, JSidePane, JSideBar, JImageViewer, XTree,
XCheckBox, JCardPane, JGridPane等一系列控件.
· 图形控件
提供了常见的图形, 2D图形和3D图形.
· 图表控件
支持3种不同的图表类型, 分别是饼形图,条形图和线形图.
· 核心公式框架
核心公式框架定义了一个通用的公式框架,包括函数和公式定义,公式解析器等接口。
· JDataGrid核心控件
· 普通文件格式的输入和输出
支持输入和输出多种文件格式,包括csv, html, txt.
· JDataGrid电子表格控件
JDataGrid电子表格控件是了一个Java
swing 电子表格控件,提供了基本的功能,如撤销和重做,合并单元格,拼写检查,Excel文件的输入和输出,打印和打印预览等,也包括了复杂的高级功能.
· 电子表格公式
支持许多函数,例如逻辑函数, 日期函数, 数学计算函数, 文本函数, 单元格函数, 和部分的统计函数.
· 高级文件格式的输入和输出
支持输入和输出多种文件格式,包括Excel xls, Excel xml, PDF等.
· JDataGrid电子表格JavaFX控件
最新的JDataGrid电子表格控件支持JavaFX平台,新添加了JavaFX控件"DataGrid"和"DataGridBean",您可以在JavaFX脚本中直接使用这些控件,这些JavaFX控件直接支持最新的JDataGrid电子表格服务器端控件。
· JDataGrid电子表格JavaEE服务器端控件
最新的JDataGrid电子表格服务器端控件能部署在JavaEE应用服务器上,JDataGrid小程序直接支持最新的服务器端控件,您可以通过简单的设置,设置一个服务器端控件的URL,就能读取,保存,下载各种不同格式的电子表格文件,所有的配置在服务器端完成。
· JDataGrid数据库控件
JDataGrid数据库控件是一个能够直接对数据库操作的表格,基于标准的JDBC技术,能够直接操作ResultSet和RowSet,并提供如打印和打印预览,多种格式的文件输入和输出的功能.
摘要: 新功能介绍:
3.0版本添加了最新的JDataGrid电子表格服务器端控件,JDataGrid小程序直接支持最新的服务器端控件,您可以通过简单的设置,设置一个服务器端控件的URL,就能读取,保存,下载各种不同格式的电子表格文件, 所有的配置在服务器端完成。
3.0版本添加了JDataGrid JavaFX 控件"DataGrid"和"DataGridBean",您可以在JavaFX脚本中直接调用 这些控件,这些JavaFX控件直接支持最新的JDataGrid电子表格服务器端控件。
阅读全文
JCalendar new features in JComponentPack
- New property to control the action click count
- New client property to control the "today” button action behavior
- JCalendar works with AComboBox and add new calendar popup icon.
1. New property to control the action click count
JCalendar provides new property named “actionClickCount” since
JComponentPack 1.1.0, use this property, you can set the mouse click count to fire the action event, JCalendar adds the following methods:
JCalendar.getActionClickCount();
JCalendar.setActionClickCount(int);
2. New client property to control the "today” button action behavior
With this new client property “JCalendar.todayButtonFireActionEventEnabled” since
JComponentPack 1.1.0, the JCalendar can fire the action event when the today button clicked.
The above new features is very important when JCalendar working with
the AComboBox, the the popup JCalendar make visible, by using the above
property, the popup can hidden when use click a "today” button or
select a specified day.
3. JCalendar works with AComboBox and add new calendar popup icon.
When AComBoBox set a Date value , the popup icon automatically became a calendar icon, this is a nice feature since
JComponentPack 1.1.0, see the screenshot for this feature:
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:
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:
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:
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:
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);
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:
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.