The Complete Client for the Java Platform
Michael C. Albers
Jeff Dunn
Norbert Lindenberg
Sun Microsystems, Inc.
Goal: Prototype ® Application
Learn how to transform an application prototype into a shipping application. Through demonstrations and code samples, we will discuss effective user interface design, accessibility, and internationalization
Objectives
As a result of this presentation, you will
be able to create an application that:
- Has a clean, polished look
- Behaves as users expect
- Is usable by people with disabilities
- Is tuned for people in any country
Speakers
Michael C. Albers
User Experience Lead
Java[TM] 2 Platform, Standard Edition
Jeff Dunn
Accessibility Engineer
Sun Microsystems, Inc.
Norbert Lindenberg
Internationalization Engineer
Java[TM] 2 Platform, Standard Edition
Your Task: Requirements
Developer at a Global 2000 company
Create a lightweight communication tool
- Cross platform
- Support geographically separated groups
- E-mail too heavyweight and too slow
- Web-based chat not interactive enough
Your Solution: Instant Messenger
Distribute via Java Web Start software
Communication via servlets
Developed a quick prototype UI
Management loves it
- Deploy in 60 days
- Deploy worldwide
- Support all users
Steps to a Complete Client
1. Standard Graphical Style
2. Standard Wording
3. User Interface Localization
4. Layout
5. Keyboard Navigation
- Shortcuts and Mnemonics
- Traversal
Steps to a Complete Client
6. Adaptations for Users with Disabilities
- Accessible Name and Description
7. Cultural Conventions
8. Text Editing
Standard Graphical Style
Use the graphics repository
- http://developer.java.sun.com/developer/
techDocs/hi/repository/
Follow the style provided in the Java Look and Feel design guidelines
- http://java.sun.com/products/jlf2/book/
HIG.Graphics.html
Standard Graphical Style: Samples
Standard Wording: Terminology
Use common, user-understandable terms
Use the recommendations in the Java
Look and Feel design guidelines
- General
- http://java.sun.com/products/jlf2/book/
HIG.Visual3.html
- Menus
- http://java.sun.com/products/jlf2/book/
HIG.Menus2.html
Standard Wording: Samples
User Interface Localization
Use resource bundles to store objects that
may need to change for other languages
or countries
User Interface Localization:
Code Sample
Instead of hardcoded strings:
- JMenu editMenu = new JMenu("Edit");
Use ResourceBundle:
- ResourceBundle bundle =
- ResourceBundle.getBundle("MsgRes");
- JMenu editMenu =
- new JMenu(bundle.getString("editMenu"));
And localized resource bundles:
- editMenu = Edit
- editMenu = Bearbeiten
Layout: Orientation
Layout managers resize automatically to handle changes in text length and font size
Layout managers handle component orientation automatically if they can
Layout: Code Sample
Applications should avoid specifications that prevent automatic component orientation
Instead of absolute coordinates:
- LEFT, RIGHT
- NORTH, SOUTH, EAST, WEST
- NORTHWEST, SOUTHEAST
Use relative coordinates:
- LEADING, TRAILING
- PAGE_START, PAGE_END, LINE_START, LINE_END
- FIRST_LINE_START, LAST_LINE_END
Layout: Spacing
Create spacing as specified in the Java
Look and Feel design guidelines
- General Information
- http://java.sun.com/products/jlf2/book/
HIG.Visual2.html
- Button Spacing
- http://java.sun.com/products/jlf2/book/
HIG.Visual2.html#80100
Keyboard Navigation:
Shortcuts and Mnemonics
Mouseless operation is crucial
All windows need an initial focus owner
Use the shortcuts and mnemonics provided in the Java Look and Feel design guidelines
- Mnemonics for all focusable components
- Shortcuts for commonly-used actions
Keyboard Navigation:
Code Sample
Default focus component:
Mnemonics:
Keyboard Navigation:
Traversal
Tab traversal of components should make sense from the user perspective
- Use JComponents setNextFocusableComponent() method
- Subclass javax.swing.FocusManager
- New focus subsystem in the future
Use the recommendations in the Java
Look and Feel design guidelines
Adaptations for Users
With Disabilities
Accessible Name
- Short string
- Communicated often
- Defaults to components static text
Accessible Description
- Longer string
- Communicated when requested
- Defaults to tooltip
Adaptations for Users
With Disabilities: Code Sample
Example of overriding the AccessibleName
and AccessibleDescription:
Cultural Conventions
Cultural conventions vary
- Calendars
- Date, time, number formatting
- Text comparison
- Text breaking
- Address and telephone number formatting
- Greetings and honorifics
The Java platform supports many of them
Cultural Conventions
Code Sample: Date Formatting
Instead of Date.toString:
- String dateString = (new Date()).toString();
Use DateFormat:
- DateFormat dateFormat = DateFormat.getInstance();
- String dateString = dateFormat.format(new Date());
Cultural Conventions
Code Sample: String Comparison
Instead of string comparison by code point:
- Arrays.sort(addressees);
- boolean before = s1.compareTo(s2) < 0;
Use Collator:
- Collator collator = Collator.getInstance();
Arrays.sort(addressees, collator);
- Collator collator = Collator.getInstance();
boolean before = collator.compare(s1, s2) < 0;
Text Editing: Display/Input/Editing
With the Java Foundation Classes (JFC/Swing) API, much works by default
- Text display
- Text input and editing
You need to commit text before saving, printing, or sending:
- textField.getInputContext().endComposition();
Summary
A straightforward set of steps can lead you from a prototype application to a polished, professional application
Correctly utilizing the internationalization
and accessibility features of the Java
platform is easy
Many resources are available to aid you in creating professional applications for the
Java platform
Resources: Sessions and BOFs
TS-1315 Focus on Focus
Wed., 11:00am
BOF-1325 Java Foundation Classes API
Wed., 7:00pm
BOF-2800 AWT
Wed., 8:00pm
TS-1318 Java Web Start software
Thurs., 11:00am
TS-1459 Java Look and Feel Design Guidelines
Thurs., 1:30pm
BOF-1336 Internationalization
Thurs., 8:00pm
Resources: Web Sites and Books
Web sites
- http://java.sun.com/j2se/1.3/docs/guide/intl/
- http://java.sun.com/products/jlf2/
- http://developer.java.sun.com/developer/
techDocs/hi/repository
- http://www.sun.com/access/
Books
- Java Look and Feel Design Guidelines, 2nd ed.
- Deitsch, Czarnecki: Java Internationalization