LOGGING / NOTES</>↗Logging17 Feb 2009
When logging some messages in our application the purpose could be creating a log for debugging purposes. To minimize the impact of these debug message we can use a conditional logging. To do this we need to wrap each call to the logger method with a Logger.isLoggable(Level level) check. The check will ensure that only […]
LOGGING / NOTES</>↗Logging16 Feb 2009
In this example you can see how we can log an exception when it occurs. In the code below we are trying to parse an invalid date which will give us a ParseException. To log the exception we call the Logger.log() method, passes the logger Level, add some user-friendly message and the Throwable object. package […]
LOGGING / NOTES</>↗Logging12 Feb 2009
The Logger class provide a setLevel() method to set the logging level. By setting logging to a certain level we can control which message will be logged. To determine or check if a message will be logged we can use the Logger.isLoggable(Level level) method. Let see the example below. package org.kodejava.util.logging; import java.util.logging.Logger; import java.util.logging.Level; […]
LOGGING / NOTES</>↗Logging09 Feb 2009
Since JDK 1.4 a logging API was introduced into the Java class libraries. This API enables our application to logs some messages to record our application activities. To create an instance of Logger we can call the Logger.getLogger() factory method which will return the available logger for the given namespace, or it will create a […]
SWING / NOTES</>↗Swing08 Feb 2009
In this example we create a compound border, a border around border. Here, instead of creating a new instance of Border class directly we create the border using the BorderFactory factory class. package org.kodejava.swing; import javax.swing.*; import javax.swing.border.BevelBorder; import javax.swing.border.Border; import java.awt.*; public class CompoundBorderExample extends JFrame { public CompoundBorderExample() { initializeUI(); } public static […]
SWING / NOTES</>↗Swing05 Feb 2009
This example shows you how to create a border that have a title in it. There is a special border class the TitledBorder that does this. We can define the justification of the title, left, centered or right justify. To do this we call the setTitleJustification() method. We can also set other attributes such as […]