Tag Archives: java

Recent FAQ for Java Spreadsheet

JDataGrid is a pure Java Spreadsheet component, it has many features, it looks like Excel, the following is the questions that the developers often ask, it will help you understand and use the JDataGrid quickly.

Q:How to enable multiple in cell?
A:Sets the cell to String.class:
dataGridModel.setCellClass(String.class, 3, 5); then enable multiple line:
((StringCellEditor)dataGrid.getCellManager().getCellEditor(String.class)).setMultiLine(true);
((StringCellRenderer)dataGrid.getCellManager().getCellRenderer(String.class)).setMultiLine(true);

Q:How to click once, then enter edit mode?
A:dataGrid.putClientProperty(“JDataGrid.clickCountToStartsEdit”, 1);

Q:How to set the JDataGrid window size?
A:

bean.getFrame(true).setPreferredSize(new Dimension(480,320));

bean.setExtendedState(Frame.NORMAL);

Q:How to disable the save/cancel dialog after close the JDataGrid window?
A:Override the JDataGridBean.doClose method,add your logic, then getFrame().dispose() method.

Q:How to set the freeze window on code?
A:JDataGrid.setFreezeCell

Q:How to get the menu on the top?
A:

JMenu menuwindow =(JMenu) menubar.getMenu(6);

dataGridBean.getUIFactory().loadMenu(menuwindow);

Q:How to add license data?
A: LicenseManager.getInstance().addLicenseData(registercode);

Q:How to get selected cells of JDataGrid?
A:Cell[]  cells = getDataGrid().getSelectedCells();
Cell   c =  getDataGrid().getSelectedCell();

Q:How to hide the default menu bar of JDataGrid?
A:JMenuBar menubar = dataGrid.getMenuBar(JDataGridBean.MAIN_MENUBAR);
menubar.setVisible(false);

Q:Have the JDataGrid auto increment the row or column count when click the scrollbar?

A:Set the following property to enable this feature:
JDataGridBean.setAutoAdjustRowColumCount(true);

Q:Is the maximum row and column count of JDataGrid?
A:In theory, the JDataGrid support maximum 2^32 row or column count, on the bank or securities project, they always use the LargeDataGridModel, it have better performance for large data.

 

 

How to disable JDataGridBean splash screen?

Before initialize the JDataGridBean component, set the following system property at first:

System.setProperty(“application.hideSplash”, “true”);

JDataGrid is a Java Excel swing component in JComponentPack product suite, it’s a flexible Java spreadsheet, it’s widely used in banking, securities, taxation, e-government system.

JDataGridBean is a component based on JDataGrid and provide menu bar, tool bar, status bar, etc.

JDataGrid and JDataGridBean could both used in your swing application.

How to use DataGridModelAdapter?

DataGridModelAdapter is a adapter,could convert any TableModel to DataGridModel, and used in JDataGrid,JDataGrid could use the TableModel directly,but if use the DataGridModelAdapter wrap your TableModel,your TableModel could set cell style, merge and split cell, your TableModel need not any changes.

Code Sample:

JDataGrid is a Java Excel swing component in JComponentPack product suite, it’s a flexible Java spreadsheet, it’s widely used in banking, securities, taxation, e-government system.

jzip v1.1

jzip v1.1

jzip is a multiple thread zip tool, compress files into part by thread count.

Before run this tool, setup environment variable named JZIP_HOME,point to this tool:

set JZIP_HOME=E:\jzip-1.1\

Then run:

jzip -n3 databases-n3.zip databases
jzip databases.zip databases

Options:

-n thread count, for example: -n4 means 4 thread
-b input buffer size, for example: -b32768 means input buffer is 32k
-o output buffer size, for example: -o32768 means output buffer is 32k
-d date pattern, for example: -dyyyyMMddHHmmss means append date with hours, minutes, seconds

jzip -b32768 -o32768 -dyyyyMMddHHmmss -n4 databases-n4.zip databases

Feedback or Send message to me:

http://www.zfqjava.com/blog

Download: jzip-1.1.zip

Java odd methods

Swing:

“javax.swing.JScrollPane.add(Component)” method cannot work, should use “JScrollPane.setViewportView(Component)” method.

Write a javax.swing.text.DocumentFilter, should override the “replace” method too, the “insertString” cannot be invoked on editing.

Util:

java.util.Date, the method getXXX is deprecated, but new Date() is not, why not add new method like “getCalendarYear()” and keep consistent with the Calendar behavior,the “Calendar.get(Calendar.YEAR) – 1900″ is hard to use and error-prone.

java.util.Collection, the method “add” and “addAll” is error-prone for add collection, should use “put” to put single object, “addAll” for collection.

NetBeans is my favorite Java IDE

NetBeans is slow, and occupy large memory footprint, but is very powerful, I like the refactor functionality, I always change the code, before expose to public API, modify it again and again, move class to new package, split one class to abstract class and subclass, override method of super class, auto generate setter and getter, hashCode and equals methods, NetBeans make the efficiency multiplied, reduce my time to do the heavy and repetitive work.

The NetBeans community also provide many third party plugins, I also write several NetBeans plugins, one of the plugins is “Merge Properties File“, it’s completely free, you may not use it everyday, but when you need use it, you will find it’s very useful.

How to use this plugin, if you want refactor some package or module, merge several package or module to one, the properties file could be merged together by use this plugin, select all the file nodes you want to merge on the project tree, then on the context menu, choose this plugin, it will merge all properties automatically, also give you GUI to resolve the conflicts, the different locale also be determined automatically.

JavaFX 2.2 First Look

JavaFX 2.2 is released and bundle with JavaSE 7u6, it seems the support  for media functionality have not open API for swing component directly, the GUI looks good, it’s performance still have some serious problem, JavaFX Sence Builder is written by JavaFX, I use it for a while, sometimes the whole UI is frozen.

I hope all the nice features such as rich medial support, native web browser can be used in Swing component directly, we need not use JavaFX for business desktop.