Monthly Archives: September 2012

Java odd methods


“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.


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.