BASIC / CATATAN</>↗Basic28 Jun 2008
To mark a method as deprecated we can use the JavaDoc @deprecated tag. This is what we did since the beginning of Java. But when a new metadata support introduced to the Java language we can also use annotation. The annotation for marking method as deprecated is @Depreated. The difference between these two that the […]
CORE API / CATATAN</>↗Core API24 Jun 2008
This example using the Java Compiler API introduced in JDK 1.6 to programmatically compile a Java class. Here we’ll compile the Hello.java. The process of compiling can be start by obtaining a JavaCompiler from the ToolProvider.getSystemJavaCompiler(). The simplest way to compile is by calling the run() method of the compiler and passing the first three […]
BEANS / CATATAN</>↗Beans24 Jun 2008
package org.kodejava.bean; import java.io.Serializable; import java.beans.BeanInfo; import java.beans.Introspector; import java.beans.PropertyDescriptor; import java.beans.IntrospectionException; public class Fruit implements Serializable { private Long id; private String name; private String latinName; private double price; public Fruit() { } public static void main(String[] args) { try { BeanInfo bi = Introspector.getBeanInfo(Fruit.class); PropertyDescriptor[] pds = bi.getP...
BEANS / CATATAN</>↗Beans20 Jun 2008
package org.kodejava.bean; import java.io.Serializable; import java.io.IOException; import java.beans.Beans; public class TheBean implements Serializable { private Long id; private String name; public TheBean() { } public static void main(String[] args) { try { TheBean bean = (TheBean) Beans.instantiate( ClassLoader.getSystemClassLoader(), "org.kodejava.bean.TheBean"); bean.setId(1L); bean.setName("John"); System.out.println("The Bean = " + bean); } catch (IOException | Class...
BEANS / CATATAN</>↗Beans16 Jun 2008
The constrained property change is fired when a bean’s value is about to change. When a VetoableChangeListener veto the value change the bean’s value will be rolled-back to the previous value. In this example we have a constrained property called interest. package org.kodejava.bean; import java.beans.VetoableChangeSupport; import java.beans.PropertyVetoException; public class VetoBean { private double interest; private […]
BEANS / CATATAN</>↗Beans12 Jun 2008
In this example we’ll listen to bean’s property change event. We create a small bean named MyBean, adds attributes and getter/setter. We want to know or to get notified when the bean property name is changed. First we need the add a PropertyChangeSupport field to the bean, with this object we will fire the property […]