what is new in j2se 5

26
JACCRA R

Upload: frank-appiah

Post on 14-May-2015

398 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: What is new in J2SE 5

JACCRA

R

Page 2: What is new in J2SE 5

Frank AppiahSoftware Developer

SWGlobal Ltd

J2SE 5

http://frankappiahnsiah.wordpress.com

JACCRA

Page 3: What is new in J2SE 5

IntroductionJava Buzzwords Simple Secure Portable Object-oriented Distributed Robust Multithreaded

JACCRA

Page 4: What is new in J2SE 5

R

JACCRA

Page 5: What is new in J2SE 5

J2SE LanguageThis is the fundamental of the other two

languages/platforms.It consist of JDBC, Swing, RMI etc.

JACCRA

Page 6: What is new in J2SE 5

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

Page 7: What is new in J2SE 5

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

Page 8: What is new in J2SE 5

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

Page 9: What is new in J2SE 5

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

Page 10: What is new in J2SE 5

EnumerationIt offers elegant, structured solution to a

variety of programming task. public enum color{red, green, yellow, blue}

JACCRA

Page 11: What is new in J2SE 5

What can enumeration do for me?Clearity/Readability of codeReusing of constant values

Example : Modelling a traffic light with enumeration

JACCRA

Page 12: What is new in J2SE 5

TrafficLightColor enum TrafficLightColor { RED, GREEN, YELLOW }

The color of lights modelled with enumeration.

Page 13: What is new in J2SE 5

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.}

}

Page 14: What is new in J2SE 5

Reflection : java.lang.reflect.*MethodParameterFieldModifierClass

JACCRA

Page 15: What is new in J2SE 5

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

Page 16: What is new in J2SE 5

Annotations : java.lang.annotationAnnotations in J2SE 5 for documentations. @Deprecated @version : Indicating the version of code @author : To show the developer’s name

JACCRA

Page 17: What is new in J2SE 5

What can annotations do for me?Adding stereotype to classes to add

additional functionalityBetter maintainability

JACCRA

Page 18: What is new in J2SE 5

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.

Page 19: What is new in J2SE 5

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

Page 20: What is new in J2SE 5

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

Page 21: What is new in J2SE 5

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

Page 22: What is new in J2SE 5

Further Reading http://java.net.dev : SwingX, Swinghttp://www.swinglabs.org : SwingXhttp://www.pushing-pixels.org: Flamingohttp://frankappiahnsiah.wordpress.com :

SwingX

JACCRA

Page 23: What is new in J2SE 5

Questions ?

JACCRA

Page 24: What is new in J2SE 5

JACCRA

Page 25: What is new in J2SE 5

JACCRA

Page 26: What is new in J2SE 5

JACCRA