MAIL / NOTES</>↗Mail25 Apr 2012
To ask Java mail to print out a debug message when you run a Java mail program you can add the mail.debug and set the value to true into the properties used to create the session object. The other way is to set the debug setting of the session using the session.setDebug() method and pass […]
MAIL / NOTES</>↗Mail09 Apr 2012
This code snippet shows you how to validate an email address using the javax.mail.internet.InternetAddress class. The validate() method throws a javax.mail.internet.AddressException when the email address passed to the constructor is not a valid email address. Here is the complete code snippet: package org.kodejava.mail; import javax.mail.internet.AddressException; import javax.mail.internet.InternetAddress; public class ValidateEmail { public static void main(String[] […]
SPRING CORE / NOTES</>↗Spring Core09 Apr 2012
When many beans in a context definition will have the same initialization and destroy method name, you can define a default-init-method and default-destroy-method in the attributes of the beans element. This way you don’t have to define individual init-method and destroy-method for each of your beans. When the beans do not supply the method that […]
CORE API / NOTES</>↗Core API07 Apr 2012
The following example use the java.io.FileInputStream class to read contents of a text file. We’ll read a file located in the temporary directory defined by operating system. This temporary directory can be accessed using the java.io.tmpdir system property. package org.kodejava.io; import java.io.File; import java.io.FileInputStream; import java.io.IOException; public class FileInputStreamDemo { public static void main(String[] args) […]
SPRING CORE / NOTES</>↗Spring Core01 Apr 2012
In the other example, How do I initialize and destroy beans in Spring? you can see how to initialize and destroy a bean using the Spring configuration init-method and destroy-method. In the following example you’ll see how to achieve the same thing using the Spring API. In this case our class need to implements the […]
SWING / NOTES</>↗Swing23 Mar 2012
The following example demonstrate how to disable some keys in JTextArea and JScrollPane using the InputMap. In the disableKeys() method below we disable the arrow keys including the UP, DOWN, LEFT and RIGHT. Let’s see the code snippet below: package org.kodejava.swing; import javax.swing.*; import java.awt.*; public class TextAreaDisableKeyDemo extends JFrame { public TextAreaDisableKeyDemo() { initialize(); […]