Log4J is the current de facto standard not only in open source development. It claims to be fast and flexible: speed first, flexibility second. But there are some pitfalls when it comes to the crunch. The costs of a log request consists of a method invocation and an integer comparison. This is typically about 1-20ns (depending on your processor) per… Read more »
Deep down in the Java-API: http://java.sun.com/javase/6/docs/api/java/io/FileWriter.html Convenience class for writing character files. The constructors of this class assume that the default character encoding and the default byte-buffer size are acceptable. To specify these values yourself, construct an OutputStreamWriter on a FileOutputStream. So, if you want to write you XML-Document to a file, for the love of god, don’t use the… Read more »
If you don’t need a scaled instance of your BufferedImage in the memory, you can use “on-the-fly scaling”. For example, this custom JComponent can be used to display a BufferedImage and zoom it with the setScaleFactor(..)-method For some benchmarking on the different RenderingHints values see Chris Campbell’s great article The Perils of Image.getScaledInstance() Resources: http://java.sun.com/docs/books/tutorial/2d/advanced/quality.html http://today.java.net/pub/a/today/2007/04/03/perils-of-image-getscaledinstance.html
In short: setSize(..) doesn’t work at all, you’ll need setPreferredSize(..) followed by revalidate() Resources: http://java.sun.com/docs/books/tutorial/uiswing/components/scrollpane.html#update
Netbeans’ GUI builder is great. It’s one of the essential features that made me drop eclipse. But designing accurate GUIs can be a pain in the arse. Especially, when you use the GUI builder with a certain preview Look and Feel (e.g. GTK+) but you application later runs with a completely different L’n’F (e.g. Nimbus). It’s almost certain, that your… Read more »
Simple question, simple answer:
When designing a generic class which needs a parameter that is comparable you will probably end up with something like this: Unfortunately, using Comparable isn’t as “easy”. The Page interface described above can’t be instantiated for a type like java.sql.Time, which is not Comparable to itself, but to a supertype (i.e., java.sql.Time implements Comparable<java.util.Date>). David Hall suggests: “If you’re going… Read more »
There is a nice java tutorial from Sun how to use ReseouceBundle for localization: http://java.sun.com/docs/books/tutorial/i18n/resbundle/propfile.html. It’s actually rather simple: Just create a new ResourceBundle object by invoking the getBundle method, specifying the base name and Locale: The getBundle method first looks for a class file that matches the base name and the Locale. If it can’t find a class file,… Read more »
Recently (well, yesterday to be exact) I was really sold on a a syntax highlighting plugin for WordPress called WP-Syntax. Basically, I am still. It is still easy to use, looks good and comes with a huge variety of supported languages. But if you ask the WordPress-guys it isn’t first choice. In their FAQ they point you to Alex Gorbatchev’s… Read more »
I just ran into WP-Syntax which is a syntax highlighting plugin for WordPress using GeSHi. It supports a wide range of popular languages (including of course Java!). Examples? Here we go: 1 2 3 4 5 public class Hello { public static void main(String[] args) { System.out.println("Hello world!"); } }public class Hello { public static void main(String[] args) { System.out.println("Hello… Read more »