what is new in j2se 5
TRANSCRIPT
JACCRA
R
Frank AppiahSoftware Developer
SWGlobal Ltd
J2SE 5
http://frankappiahnsiah.wordpress.com
JACCRA
IntroductionJava Buzzwords Simple Secure Portable Object-oriented Distributed Robust Multithreaded
JACCRA
R
JACCRA
J2SE LanguageThis is the fundamental of the other two
languages/platforms.It consist of JDBC, Swing, RMI etc.
JACCRA
Topics to discussWhat is new in J2SE 5 ? - Generics - Annotations - Enumerations - Auto boxing - Variable Length Argument Additional : ReflectionsGUI Programming in JAVA - Swing - SwingX >Extension of Swing :
http://www.swinglabs.org - Flamingo
JACCRA
GenericsIt enable you to create classes, interfaces,
and methods in which the type of data upon which they operate is specified as parameter.
Merit It automatically work with the type of data
passed to its parameter.
JACCRA
Simple Example Generic with a single parameter public class Indexer<T> { T entity;public Indexer(T entity){ this.entity=entity;}public void index(){ //implement code.}public T getEntity(){ return this.entity;} } Generics also support two type parameters Support for wildcard arguments ?
JACCRA
Bounded Parameter public class Indexer<T implements Serializable> { T entity;public Indexer(T entity){ this.entity=entity;}public void index(){ //implement code.}public T getEntity(){ return this.entity;} }
JACCRA
EnumerationIt offers elegant, structured solution to a
variety of programming task. public enum color{red, green, yellow, blue}
JACCRA
What can enumeration do for me?Clearity/Readability of codeReusing of constant values
Example : Modelling a traffic light with enumeration
JACCRA
TrafficLightColor enum TrafficLightColor { RED, GREEN, YELLOW }
The color of lights modelled with enumeration.
TrafficLightSimulator class TrafficLightSimulator implements Runnable { boolean stop=false; private TrafficLightSimulator tlc; Thread thread; TrafficLightSimulator(TrafficLightColor init){ tlc=init; thread=new Thread(this); thread.start();} public void run { //if stop is not true, check color
in a switch statement and wait for some time then change color.}
}
Reflection : java.lang.reflect.*MethodParameterFieldModifierClass
JACCRA
What can reflection do for me?Externalizing of configuration classes.More Decoupling
Frameworks like Spring, Seam and Web Beans (EJB 3.1) uses this feature a
lot.
JACCRA
Annotations : java.lang.annotationAnnotations in J2SE 5 for documentations. @Deprecated @version : Indicating the version of code @author : To show the developer’s name
JACCRA
What can annotations do for me?Adding stereotype to classes to add
additional functionalityBetter maintainability
JACCRA
Creating a simple annotation@Retention(RetentionPolicy.RUNTIME)@Target(ElementType.TYPE)public @interface Model { String name() default "model";}
@Retention(Runtime) : allow your annotation to be visible at runtime.
@Target(Type) : can be applied on classes only.
Using the @Model annotation @Model(name=“student”) public class Student { String firstname; String lastname;} In order to make use of annotation
meaningfully, you have write your own custom code.
It is not exhausted here
AutoboxingConvert a primitive type into its equivalent
wrapper Example : int intobj=100;Integer value=intobj;
Auto-unboxing : Convert a wrapper into its equivalent primitive
type.
Example : Integer intObj=1000; int value=intObj
JACCRA
Flamingo Application menu button and application menu Application title bar Resize and resize sequencing policies Scrolling shrinked ribbon content Rich tooltips Key tips Ribbon minimized mode Visual groups in ribbon bands Ribbon flow bands Hosting core Swing components in ribbon Rich popup panels Ribbon help button A03 plugin for Flamingo High fidelity Substance skins Polished command button strip visuals Control over command button gap scaling
JACCRA
Further Reading http://java.net.dev : SwingX, Swinghttp://www.swinglabs.org : SwingXhttp://www.pushing-pixels.org: Flamingohttp://frankappiahnsiah.wordpress.com :
SwingX
JACCRA
Questions ?
JACCRA
JACCRA
JACCRA
JACCRA