What is new in J2SE 5

616 views

Published on

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
616
On SlideShare
0
From Embeds
0
Number of Embeds
11
Actions
Shares
0
Downloads
6
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

What is new in J2SE 5

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

×