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 JListViewcomponent meets your requirements exactly.
The JListViewcomponent
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 JListViewcomponent.
The JListViewcomponent use a ListSelectionModelas
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 JListViewcomponent also support row sorting, the TableModelyou provided for JListViewonly 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 JListViewcomponent provides several important client property:
For details, you can view the JListViewJavaDoc API documentation.
The JListViewalso 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);
The JListViewcomponent
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 JListViewcomponent.
The JListViewcomponent use a ListSelectionModelas
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 JListViewcomponent also support row sorting, the TableModelyou provided for JListViewonly 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 JListViewcomponent provides several important client property:
For details, you can view the JListViewJavaDoc API documentation.
The JListViewalso 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 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.
It also provides some useful methods, for example:
getExtensionNames()
Return all extension of this file filter as an array. getExtensionName ()
Return the extension of the parameter.
It could accept 3 kinds of parameter, a File, a String, an URL. getNameWithoutExtension(String name)
Returns the file name without extension, for example the file "readme.txt" will return "readme", include the absolute path. getPreferredExtensionName()
Returns the preferred extension of this file filter, actually is the
first extension of your extensions. It equal this operation getExtensionNames()[0].
It inherits from FileFilter, have two Constructors to create a instance of the FileFilter.
DefaultFileFilter(String ext, String description)
The first parameter is extension, the second parameter is description of extension. DefaultFileFilter(String[] ext, String description)
The first parameter are extensions, the second parameter is description of extensions.
JBasicChart provides a basic chart component.
It could draw 3 styles graph, for example: PIE, LINE, BAR.
The following code demonstrates how to use JBasicChart.
JBasicChart basicChart = new JBasicChart();
basicChart.setModel(createBasicChartModel());
basicChart.setChartType(ChartType.BAR);
It is easy to use JBasicChart, you could use method setModel(model)
to change the data which displayed on the chart, and also you could use
method setChartType(type) to change the style of the chart, the
parameter type is one of the three
values(ChartType.BAR、ChartType.LINE、ChartType.PIE).
To change the data of the chart, you should learn more about DefaultBasicChartModel. addSeries(String name,
double[] values),this method add a series values which will be y-axis
value, each value have a category name, use the method setCategoryName(String name, int categoryIndex) to set it. addSeries(String name, double[] values, int index),when you saw this method, you should know this model could add multi-series values to it.
It also have some other methods which are easy to use, for example: getCategoryCount() getCategoryName(int categoryIndex) getSeriesCount() getSeriesName(int seriesIndex) removeSeries(int index)
etc.
For more information, please see DefaultBasicChartModel and JBasicChart.