Session 4: Java Core Technologies

Session 4: Java Core Technologies

Extreme Java G22.3033-007 Session 4 - Main Theme Java Core Technologies (Part II) Dr. Jean-Claude Franchitti New York University Computer Science Department Courant Institute of Mathematical Sciences 1 Agenda • Summary of Previous Session • Java AWT and Swing components • Drag and Drop • Graphics and Multimedia Components (JavaMedia) • JavaBeans • Readings • Class Project & Assignment #2b 2 1 Summary of Previous Session • Java Platforms and Features • J2SE Core Components and Optional Packages •Swing • Collections Framework • Assistive Technologies • Introduction to J2EE • XML and Java • Readings • Class Project & Assignment #2a 3 Java Technologies/Features in Scope • Technologies: • Collections Framework • Input Method Framework • Swing • Drag and Drop • JavaBeans •JNI • Security • Language Features: • Threads • Assertions 4 2 Part I User Interfacing Technology 5 AWT & Swing Components http://java.sun.com/j2se/1.4/docs/guide/swing/index.html • Swing is part of the Java Foundation Classes (JFC) • Swing implements GUI components with “PLAF” • PLAF: “Pluggable Look and Feel” • GUI components automatically adapt their look and feel to that of the OS platform • Swing includes the AWT component • Button, Scrollbar, Label, etc. • Swing also includes higher level components • TreeView, list box, tabbed panes, etc. • See Session 3 Sub-Topic 1 Presentation on Swing • See Session 3 Handout on Detailed Review of the Swing Packages 6 3 AWT & Swing Components (Java 2 SDK 1.4 Enhancements) • Indeterminate progress bars (JProgressBar) • Show that a time-consuming operation is occurring • Do not show the degree of completeness of an operation • JTabbedPane: Scrollable Tabs • Spinners • Let users select a value from an ordered set • JFormattedTextField • Supports input of dates in current locale format 7 AWT & Swing Components (Java 2 SDK 1.4 Enhancements - continued) • Popup and PopupFactory Changes • Allows popup compatibilty with custom look and feel implementations • New AWT Focus Model Specification • Windows Look and Feel Updates 8 4 Swing vs. SWT • Eclipse Open Platform for Tool Integration • 100% implemented in Java • Support extensions based on “plug-ins” • Does not use a single line of AWT or Swing! • Used the Standard Widget Toolkit (SWT) and JFace for more complex widgets, images, and font registries • SWT uses native widgets except when a class of widget is not commonly available on all target platforms. • In that case, SWT emulates the widget 9 Swing vs. SWT (continued) • SWT Advantages • GUIs look and feel exactly like native GUIs • Graphics performance is close to native • Platform-specific features can be accessed if desired • E.g., embedding ActiveX controls, and using native DnD • SWT Drawbacks • No support for pluggable look and feels • Door open to write non-portable code • See STW/Swing comparison sample program at: http://www.fawcette.com/javapro/2002_12/magazine/column s/proshop/page2.asp 10 5 SwingML (http://swingml.sourceforge.net/) • Markup language to render JFC/Swing based GUIs in a Web browser • Alternatives? • Use JSP, JavaBeans, XSLT, and Servlets to generate dynamic HTML • HTML cannot support complex functionality such as a Tree component with D&D • Use JavaScript and Applets • JavaScript support is not uniform across browsers • Applets combined with JFC/Swing components • Difficult to retrieve information from server: use RMI, HTTP Tunneling, or … XML! 11 SwingML Architecture • Server-side component produces SwingML and returns it to the client side • On the client side, an applet (“renderer”) receives the SwingML markup text and uses it to render the GUI 12 6 XML-based User Interface Language (XUL) (http://www.mozilla.org/xpfe/xptoolkit/xulintro.html) <?xml version="1.0"?> <?xml-stylesheet href="chrome://global/skin/xul.css" type="text/css"?> <!DOCTYPE window> <window id="main-window" xmlns:html="http://www.w3.org/1999/xhtml" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> <menubar> <menu name="File"> <menuitem name="Hello World!" onclick="dump('Hello world!\n');"/> </menu> </menubar> <html:iframe id="content-frame" src="contentframe.html" flex="100%"/> </window> 13 Other Rich, Cross-Platform, ZAC GUI Solutions • Known Variations • (1) Browser-plugins (a la Applets, SVG) - Flash • (2) Language (a la Java, JavaScript) - Curl, Rebol • (3) Improved HTML (a la XUL) - NexaWeb, SashXB • (4) Improved installers (a la Web Start) - AppStream • Luxor XUL (http://luxor-xul.sourceforge.net) • XML Windowing Toolkit - XWT (http://www.xwt.org) • JellySwing (http://jakarta.apache.org/commons/sandbox/jelly/jellyswing.html) •Thinlets (http://www.thinlet.com/) • KoalaGM (http://koalagml.sourceforge.net/) • Java GUI Builder (http://jgb.sourceforge.net/) • Not Yet Xulux (Nyx), Motlib.Net, Rocklyte Systems, Altio, Bali Spidertop, droplets, Ultra Light Client (ULC), Kenamea, Softricity, etc. 14 7 Light Client GUI Solutions Selection Criteria • Must be able to support alternative GUI toolkits • Sun’s Swing, Eclipse’s SWT, Trolltech Qt, Gnome Gtk+, etc. • Must be able to support various programming language engine • Java, C#, Shark, etc. 15 Part II Drag and Drop 16 8 Drag and Drop • See Session 4 Handout on Drag and Drop Data Transfer 17 New Drag and Drop Architecture http://java.sun.com/j2se/1.4/docs/guide/swing/1.4/dnd.html • Swing added support for data transfer between applications • Drag and Drop (DnD) • Clipboard transfer via cut / copy / paste • Data transfer support changes • API to enable data transfer with a few method calls • New TransferHandler class, and JComponent property methods setTransferHandler and getTransferHandler • Swing DnD implementation can be disabled to use that of AWT • Look and feel implementation changes 18 9 New Drag and Drop Architecture (Adding Dnd Support to a Label text property) JLabel componentType = new JLabel(); componentType.setTransferHandler(new TransferHandler("text")); MouseListener ml = new MouseAdapter() { public void mousePressed(MouseEvent e) { JComponent c = (JComponent)e.getSource(); TransferHandler th = c.getTransferHandler(); th.exportAsDrag(c, e, TransferHandler.COPY); } }; componentType.addMouseListener(ml); 19 Part III Java Media Framework (JMF) 20 10 Graphics and Multimedia Components • Media APIs: • Enables developers to create Java applets and applications that can handle rich, interactive media types (audio, video, 2D imaging, 3D graphics, animation, collaboration, telephony, and speech) • Java 2D (line art, text, and imaging), Java 3D, Java Advanced Imaging, Java Media Framework (JMF), Java Speech, Java Sound, Java Telephony • See Session 3 Handout on Java Platform Component APIs • See Session 4 Handout on Graphics and Multimedia Components - Java 2D 21 Part IV JavaBeans Component Architecture 22 11 JavaBeans • See Session 4 Handout on Component Modeling with JavaBeans • The JavaBeans component architecture allows reusable component development • The JavaBeans specification defines a set of standard component software APIs for the Java platforms • Javabeans components interoperate with ActiveX • JavaBeans APIs are portable to mainstream containers (IE, VB, Microsoft Word, Lotus Notes, etc.) 23 JavaBeans Enhancements in 1.4 (http://java.sun.com/j2se/1.4/docs/guide/beans/changes14.html) • New API for Long-Term Persistence • Other API Additions • Changes to the Introspector • Garbage Collection and Custom Attributes • Bean Builder 1.0 Beta • Java Web Start-enabled Visual application builder that includes source code • http://java.sun.com/products/javabeans/beanbuilder/index.html 24 12 JavaBeans Activation Framework (JAF) • Framework can be used to: • (a) determine the type of an arbitrary piece of data • (b) encapsulate access to it • (b) discover the operations available on it • (c) instantiate appropriate Beans components to perform these operations • See: • http://java.sun.com/products/javabeans/glasgow/jaf.html 25 Part V Readings and Assignment 26 13 Assignment • Readings • Mastering Java 2: Part 2 – Chap. 12-13, 15, 21 • Expert One-on-One: Chapter 2-4 as applicable (cont.) • Selected readings mentioned in class or referenced in the handouts • Handouts posted on the course web site • Assignment #2b: (submit report and implementation archive) • Add drag-and-drop facilities to the Java framework-based application developed in assignment #2a. • Extra credit: Reimplement (part of) the GUI using SWT • Refer to the Homework #2 Specification posted on the course Web site. • Project Framework Setup • J2EE IDE: IBM WSAD, WAS, DB2 • Java Plug-in, Java Web Start, Apache’s Xerces/Xalan • J2SE 1.3.1, 1.4.0 or 1.4.1 (SDK) • IDE: Eclipse, NetBeans, Sun ONE Studio, JBuilder, Visual Age, Visual Café, Codewarrior, WebGain Studio, Oracle JDeveloper, etc. • Editors: JCreator, UltraEdit, etc. 27 14.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    14 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us