developing beyond the component libraries...developing beyond the component libraries users should...

68
Developing Beyond the Component Libraries Ryan Cuprak www.cuprak.net JavaOne 2010 1

Upload: others

Post on 26-Mar-2020

27 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Developing Beyond the Component Libraries...Developing Beyond the Component Libraries Users should not know they are using a Java application. Users approach the computer as a tool

Developing Beyond the Component Libraries

Ryan Cuprakwww.cuprak.net

JavaOne 2010

1

Page 2: Developing Beyond the Component Libraries...Developing Beyond the Component Libraries Users should not know they are using a Java application. Users approach the computer as a tool

Speaker

JavaOne 2010

www.enginuityplm.com

www.ctjava.org

2

Page 3: Developing Beyond the Component Libraries...Developing Beyond the Component Libraries Users should not know they are using a Java application. Users approach the computer as a tool

What makes an application unique?

What it does.

How useful it is.

How a user interacts with it.

JavaOne 20103

Page 4: Developing Beyond the Component Libraries...Developing Beyond the Component Libraries Users should not know they are using a Java application. Users approach the computer as a tool

Agenda❖ Why write a custom component?❖ Implementing a custom component❖ Introduction to Java’s L&F❖ Extending Swing components❖ Creating novel components❖ Understanding editor integration❖ Mashing Swing and JavaFX

JavaOne 20104

Page 5: Developing Beyond the Component Libraries...Developing Beyond the Component Libraries Users should not know they are using a Java application. Users approach the computer as a tool

Developing Beyond the Component Libraries

❖ Users should not know they are using a Java application.❖ Users approach the computer as a tool for accomplishing a

task. ❖ Users should not be impeded by a user interface.❖ Users should never hear:

“You are limited to a JTextField because Java/Oracle doesn’t provide an ‘X’ GUI widget”

Java’s GUI component architecture is build for extension!

Couple of things before we get started:

JavaOne 20105

Page 6: Developing Beyond the Component Libraries...Developing Beyond the Component Libraries Users should not know they are using a Java application. Users approach the computer as a tool

❖ Button❖ Check Box❖ Color Chooser❖ Combo Box❖ Desktop Pane❖ Dialog❖ Editor Pane❖ File Chooser❖ Formatted Field❖ Frame❖ Internal Frame❖ Label

❖ Layered Pane❖ List❖ Menus❖ Option Pane❖ Panel❖ Password Field❖ Progress Bar❖ Radio Button❖ Scroll Bar❖ Scroll Pane❖ Separator❖ Slider

❖ Spinner❖ Split Pane❖ Tabbed Pane❖ Table❖ Text Area❖ Text Field❖ Text Pane❖ Toggle Button❖ Tool Bar❖ Tree

Hasn’t expanded since Swing was introduced.

Why write a custom component?

JavaOne 20106

Page 7: Developing Beyond the Component Libraries...Developing Beyond the Component Libraries Users should not know they are using a Java application. Users approach the computer as a tool

Why write a custom component?

❖ Swing component library is a starting point.❖ Applications need more than basic components:

❖ Currency Fields - support multiple currencies❖ Percent Fields - covert to PPM/PPB❖ Date Viewers - render dates❖ Numeric controls - scientific notation, locale aware❖ Text editor - highlight spelling errors

❖ Reduce redundant coding❖ Distinctive appearance

JavaOne 20107

Page 8: Developing Beyond the Component Libraries...Developing Beyond the Component Libraries Users should not know they are using a Java application. Users approach the computer as a tool

❖ Decorating components:

❖ Fields containing validation errors

❖ Fields that are required

❖ Auto-focusing on fields with validation errors

❖ Binding and sorting data

❖ Restricting or facilitating data input

❖ Adding new platform controls (Office Ribbon)

❖ Leveraging platform controls (WebKit)

Why write a custom component?

JavaOne 20108

Page 9: Developing Beyond the Component Libraries...Developing Beyond the Component Libraries Users should not know they are using a Java application. Users approach the computer as a tool

❖ Does it exist already?❖ Does the functionality really need a new component?❖ Will the component be used in an editor such as NetBeans,

IDEA, Eclipse, JFormDesigner?❖ Is the component locale sensitive?❖ Is the component Look & Feel sensitive?❖ Does it need to support accessibility?

Why write a custom component?Before rushing off to implement components:

JavaOne 2010

9

Page 10: Developing Beyond the Component Libraries...Developing Beyond the Component Libraries Users should not know they are using a Java application. Users approach the computer as a tool

❖ Swingx (swingx.dev.java.net)❖ Flamingo (flamingo.dev.java.net)❖ JIDE Software (www.jidesoft.com/)❖ ILOG (www.ilog.com)❖ Beans Binding (beansbinding.dev.java.net)❖ JGraph (www.jgraph.com)❖ ArcGIS (www.esri.com)❖ JFreeChart (www.jfree.org/jfreechart)❖ JavaFX - controls/effects (http://javafx.com)❖ TWaver - http://www.servasoftware.com

Many More!Don’t reinvent the wheel!

Why write a custom component?

Alternatives to writing a component:

JavaOne 201010

Page 11: Developing Beyond the Component Libraries...Developing Beyond the Component Libraries Users should not know they are using a Java application. Users approach the computer as a tool

Which path to take?

❖ Java Swing

❖ Java AWT

❖ JavaFX

❖ SWT

❖ LWUIT

❖ Apache Pivot

Why write a custom component?

JavaOne 201011

Page 12: Developing Beyond the Component Libraries...Developing Beyond the Component Libraries Users should not know they are using a Java application. Users approach the computer as a tool

Agenda

❖ Why write a custom component?❖ Implementing a custom component❖ Introduction to Java’s L&F❖ Extending components❖ Creating novel components❖ Understanding editor integration❖ Mashing Swing and JavaFX

JavaOne 201012

Page 13: Developing Beyond the Component Libraries...Developing Beyond the Component Libraries Users should not know they are using a Java application. Users approach the computer as a tool

❖ Create new button with a custom appearance:❖ Custom background and border❖ Dashed border around text focused❖ Underline text on roll-over❖ Use the cambria font❖ Text grows with the component

❖ Implementation:1. Subclass javax.swing.JComponent2. Override JComponent.paintComponent(),

getPreferredSize(), getMinimumSize()3. Add a FocusListener4. Add a MouseMotionListener

Implementing a custom component

JavaOne 201013

Page 14: Developing Beyond the Component Libraries...Developing Beyond the Component Libraries Users should not know they are using a Java application. Users approach the computer as a tool

Implementing a custom component

Code Demo

JavaOne 201014

Page 15: Developing Beyond the Component Libraries...Developing Beyond the Component Libraries Users should not know they are using a Java application. Users approach the computer as a tool

Approach shortcomings:

❖ Reinvents logic already in JButton.

❖ Ignores Look And Feel framework entirely.

❖ Can’t be used as a default button for a dialog.

❖ Doesn’t support HTML labels, icons, etc.

❖ Cannot be extended easily.

Implementing a custom component

JavaOne 201015

Page 16: Developing Beyond the Component Libraries...Developing Beyond the Component Libraries Users should not know they are using a Java application. Users approach the computer as a tool

Agenda

❖ Why write a custom component?❖ Implementing a custom component❖ Introduction to Java’s L&F❖ Extending components❖ Creating novel components❖ Understanding editor integration❖ Mashing Swing and JavaFX

JavaOne 201016

Page 17: Developing Beyond the Component Libraries...Developing Beyond the Component Libraries Users should not know they are using a Java application. Users approach the computer as a tool

Introduction to Java’s L&FWhat is a LookAndFeel?

❖ LookAndFeel is a set of ComponentUI classes that provide a common theme or appearance for controls.❖ Either cross platform or platform specific.

❖ Transparent to the application programmer using controls (mostly). ❖ LookAndFeels controls:

❖ Key bindings❖ Icons❖ Focus border❖ Text (Locale sensitive)❖ Consistent appearance

❖ Note: UI is skinned in JavaFX with CSS.

JavaOne 201017

Page 18: Developing Beyond the Component Libraries...Developing Beyond the Component Libraries Users should not know they are using a Java application. Users approach the computer as a tool

Introduction to Java’s L&FWhat is a LookAndFeel?

JavaOne 201018

Page 19: Developing Beyond the Component Libraries...Developing Beyond the Component Libraries Users should not know they are using a Java application. Users approach the computer as a tool

Introduction to Java’s L&FLookAndFeel Hierarchy

JavaOne 201019

Page 20: Developing Beyond the Component Libraries...Developing Beyond the Component Libraries Users should not know they are using a Java application. Users approach the computer as a tool

Introduction to Java’s L&F

JavaOne 201020

Page 21: Developing Beyond the Component Libraries...Developing Beyond the Component Libraries Users should not know they are using a Java application. Users approach the computer as a tool

Default Look & Feel

❖ MacOS X:

❖ com.apple.laf.AquaLookAndFeel

❖ Windows:

❖ javax.swing.plaf.metal.MetalLookAndFeel

Introduction to Java’s L&FWhat is a LookAndFeel?

JavaOne 201021

Page 22: Developing Beyond the Component Libraries...Developing Beyond the Component Libraries Users should not know they are using a Java application. Users approach the computer as a tool

Introduction to Java’s L&F

What are the pieces of a component in Swing?

❖Keystroke handling❖Tooltips❖Accessibility❖Client Properties

❖Painting❖Layout❖Dimensions

JComponent ComponentUI

LookAndFeel Specific

JavaOne 201022

Page 23: Developing Beyond the Component Libraries...Developing Beyond the Component Libraries Users should not know they are using a Java application. Users approach the computer as a tool

Introduction to Java’s L&FJComponent

JavaOne 201023

Page 24: Developing Beyond the Component Libraries...Developing Beyond the Component Libraries Users should not know they are using a Java application. Users approach the computer as a tool

Introduction to Java’s L&FComponentUI

JavaOne 201024

Page 25: Developing Beyond the Component Libraries...Developing Beyond the Component Libraries Users should not know they are using a Java application. Users approach the computer as a tool

Introduction to Java’s L&FComponentUI

JavaOne 201025

Page 26: Developing Beyond the Component Libraries...Developing Beyond the Component Libraries Users should not know they are using a Java application. Users approach the computer as a tool

Introduction to Java’s L&FComponentUI Instantiation

JavaOne 201026

Page 27: Developing Beyond the Component Libraries...Developing Beyond the Component Libraries Users should not know they are using a Java application. Users approach the computer as a tool

Introduction to Java’s L&FComponentUI Instantiation

JavaOne 201027

Page 28: Developing Beyond the Component Libraries...Developing Beyond the Component Libraries Users should not know they are using a Java application. Users approach the computer as a tool

Introduction to Java’s L&F

So how do we go from a ButtonUI to a MetalButtonUI or an AquaButtonUI?

JButton returns “ButtonUI”, UIDefaults it maps to a MetalButtonUI.

ComponentUI Instantiation

JavaOne 201028

Page 29: Developing Beyond the Component Libraries...Developing Beyond the Component Libraries Users should not know they are using a Java application. Users approach the computer as a tool

To sum up the creation process:1. LookAndFeel initializes and populates UIDefaults with a mapping of

UI Class Identifiers to the LookAndFeels implementations.2. JComponent subclass requests its UI delegate from the UIManager (singleton).

3. UI Manager queries the JComponent subclass for its UI Class ID.❖ ButtonUI for JButton❖ TextFieldUI for JTextField

4. UIManager looks up the UIComponent using the UI Class ID:❖ ButtonUI maps to MetalButtonUI

5. UIManager invokes static method createUI(JComponent) on the ComponentUI❖ UI delegate can be a singleton or unique for each component.

Introduction to Java’s L&FComponentUI Instantiation

JavaOne 201029

Page 30: Developing Beyond the Component Libraries...Developing Beyond the Component Libraries Users should not know they are using a Java application. Users approach the computer as a tool

Introduction to Java’s L&FSetting Bounds

Assumes a LayoutManager.JavaOne 2010

30

Page 31: Developing Beyond the Component Libraries...Developing Beyond the Component Libraries Users should not know they are using a Java application. Users approach the computer as a tool

Introduction to Java’s L&FPainting

JavaOne 201031

Page 32: Developing Beyond the Component Libraries...Developing Beyond the Component Libraries Users should not know they are using a Java application. Users approach the computer as a tool

❖ Fonts❖ Insets❖ Shadows❖ Icons❖ Borders❖ Foreground color❖ Background color

❖ Input Maps❖ Margins❖ Mnemonic❖ Opaque flag❖ Caret blink rate❖ Disabled colors❖ etc.

Introduction to Java’s L&F

UIDefaults stores settings used to by the components:

Defaults

JavaOne 201032

Page 33: Developing Beyond the Component Libraries...Developing Beyond the Component Libraries Users should not know they are using a Java application. Users approach the computer as a tool

Introduction to Java’s L&FDefaults

InstallUI method on ComponentUI loads default values.

JavaOne 201033

Page 34: Developing Beyond the Component Libraries...Developing Beyond the Component Libraries Users should not know they are using a Java application. Users approach the computer as a tool

❖ Many changes to Swing components cannot be made by simply overriding a component’s paint() method.

❖ Major changes to a component must be made in the ComponentUI:❖ Joining of cells in JTable❖ Custom popup for adding/removing table columns❖ Changing the disabled color of the text on a

JRadioButton❖ Radically changing or altering the appearance of a

component.

Introduction to Java’s L&FComponentUI

JavaOne 201034

Page 35: Developing Beyond the Component Libraries...Developing Beyond the Component Libraries Users should not know they are using a Java application. Users approach the computer as a tool

Introduction to Java’s L&F3 Steps to Component Creation

Subclass JComponent

Subclass ComponentUI

Register with UIManagerThis sounds simple right?

JavaOne 201035

Page 36: Developing Beyond the Component Libraries...Developing Beyond the Component Libraries Users should not know they are using a Java application. Users approach the computer as a tool

Agenda

❖ Why write a custom component?❖ Implementing a custom component❖ Introduction to Java’s L&F❖ Extending components❖ Creating novel components❖ Understanding editor integration❖ Mashing Swing and JavaFX

JavaOne 201036

Page 37: Developing Beyond the Component Libraries...Developing Beyond the Component Libraries Users should not know they are using a Java application. Users approach the computer as a tool

Customize three existing components:

❖ JButton - create an ObsidianButton

❖ JTextField - Currency Editor

❖ JRootPane - customize window border/buttons.

Extending ComponentsObjectives

JavaOne 201037

Page 38: Developing Beyond the Component Libraries...Developing Beyond the Component Libraries Users should not know they are using a Java application. Users approach the computer as a tool

❖ Objective implement the Obsidian Button correctly.

❖ ObsidianButton recipe:

❖ Extend ButtonUI - ObsidianButtonUI

❖ Extend JButton - ObsidianButton

❖ Register with UIManager

Extending ComponentsObsidian Button

JavaOne 201038

Page 39: Developing Beyond the Component Libraries...Developing Beyond the Component Libraries Users should not know they are using a Java application. Users approach the computer as a tool

Tidbits:

❖ ButtonModel contains the current state of the button.

❖ BasicButtonUI has hooks to ease extensions.

Extending ComponentsObsidian Button

JavaOne 201039

Page 40: Developing Beyond the Component Libraries...Developing Beyond the Component Libraries Users should not know they are using a Java application. Users approach the computer as a tool

Extending Components

Code Demo

JavaOne 201040

Page 41: Developing Beyond the Component Libraries...Developing Beyond the Component Libraries Users should not know they are using a Java application. Users approach the computer as a tool

❖ Why create a currency control?❖ Restrict user input to just numeric data.❖ Control the presentation of the currency.❖ Control the interpretation of the number.❖ Control the input of the number.

❖ Why not use JFormattedTextField?❖ How is invalid user input interpreted?❖ Controlling locale/currency settings independently.

Extending ComponentsCurrency Control

JavaOne 2010

JFormattedTextField Demo

41

Page 42: Developing Beyond the Component Libraries...Developing Beyond the Component Libraries Users should not know they are using a Java application. Users approach the computer as a tool

Extending ComponentsCurrency Control

JavaOne 2010

How is a text field rendered?

42

Page 43: Developing Beyond the Component Libraries...Developing Beyond the Component Libraries Users should not know they are using a Java application. Users approach the computer as a tool

Recipe for implementing the currency control:

1. Create a FieldView subclass to do the custom rendering.

2. Create a new BasicTextFieldUI subclass.

1. Override the create method and return the new FieldView

3. Create a new JTextField subclass

1. Return the new BasicTextFieldUI subclass

Extending ComponentsCurrency Control

43

Page 44: Developing Beyond the Component Libraries...Developing Beyond the Component Libraries Users should not know they are using a Java application. Users approach the computer as a tool

Extending Components

Code Demo

JavaOne 2010

Currency Control

44

Page 45: Developing Beyond the Component Libraries...Developing Beyond the Component Libraries Users should not know they are using a Java application. Users approach the computer as a tool

Extending Components

Food for thought:

You can radically change the rendering of a document.

Consider for example restricting input to ABCDEFG and creating a view that renders it like:

45

Page 46: Developing Beyond the Component Libraries...Developing Beyond the Component Libraries Users should not know they are using a Java application. Users approach the computer as a tool

What’s the matter with the standard JRootPane?

Extending ComponentsJRootPane

JavaOne 2010

Because sometimes you want to customize it!

46

Page 47: Developing Beyond the Component Libraries...Developing Beyond the Component Libraries Users should not know they are using a Java application. Users approach the computer as a tool

Recipe for customizing the title pane:

1.Create a JComponent subclass to render the title pane.

2.Extend RootPaneUI

3.Extend your Look And Feel:

1. In initClassDefaults perform the following configuration:JDialog.setDefaultLookAndFeelDecorated(true);JFrame.setDefaultLookAndFeelDecorated(true);

2.Return true for getSupportsWindowDecorations()

Extending ComponentsJRootPane

47

Page 48: Developing Beyond the Component Libraries...Developing Beyond the Component Libraries Users should not know they are using a Java application. Users approach the computer as a tool

Extending Components

Code Demo

JavaOne 2010

JRootPane

48

Page 49: Developing Beyond the Component Libraries...Developing Beyond the Component Libraries Users should not know they are using a Java application. Users approach the computer as a tool

❖ Why write a custom component?❖ Implementing a custom component❖ Introduction to Java’s L&F❖ Extending components❖ Creating novel components❖ Understanding editor integration❖ Mashing Swing and JavaFX

Agenda

JavaOne 201049

Page 50: Developing Beyond the Component Libraries...Developing Beyond the Component Libraries Users should not know they are using a Java application. Users approach the computer as a tool

❖ Components to be demoed:❖ iPhone Switch Component

❖ What we will see:❖ Supporting multiple Look & Feels❖ Handling focus and keyboard events

Creating Novel Components

JavaOne 201050

Page 51: Developing Beyond the Component Libraries...Developing Beyond the Component Libraries Users should not know they are using a Java application. Users approach the computer as a tool

Creating Novel ComponentsLet’s look at replicating the iPhone switch. ❖ Simple “Toggle” button that slides

back and forth for On and Off.❖ Tapping on the opposite state causes

the button to toggle with a visible animation.

❖ Dragging the switch with the mouse moves the button.

❖ Releasing the button causes the button to snap the nearest side.

JavaOne 201051

Page 52: Developing Beyond the Component Libraries...Developing Beyond the Component Libraries Users should not know they are using a Java application. Users approach the computer as a tool

Creating Novel Components

❖ Gradient Paints

❖ Rounded Borders

❖ Not 50/50

❖ Highlights

❖ Border effects

52

Page 53: Developing Beyond the Component Libraries...Developing Beyond the Component Libraries Users should not know they are using a Java application. Users approach the computer as a tool

Creating Novel Components1. JComponent Approach

1. Subclass JComponent.2. Override

paintComponent()2. LookAndFeel Approach

1. Subclass JToggleButton2. Create a ComponentUI

subclass.

JavaOne 201053

Page 54: Developing Beyond the Component Libraries...Developing Beyond the Component Libraries Users should not know they are using a Java application. Users approach the computer as a tool

❖ Implement listeners for:FocusLister, MouseListener, MotionListener, KeyboardListener

❖ Track and render states:Focus, Enabled/Disabled

❖ Support Accessibility❖ Match L&F Appearance/Theme❖ Paint the control (and have it look professional)

Creating Novel ComponentsJComponent Approach Challenges

This is not trivial!

JavaOne 201054

Page 55: Developing Beyond the Component Libraries...Developing Beyond the Component Libraries Users should not know they are using a Java application. Users approach the computer as a tool

❖ Matching current L&F is not trivial:❖ Borders❖ Shadowing❖ Font❖ Background/Foreground Colors❖ Painting (gradients)❖ Keybindings

❖ Matching multiple L&F is even more challenging.❖ Users change themes (Windows Appearance settings).

Creating Novel ComponentsJComponent Approach Challenges

JavaOne 201055

Page 56: Developing Beyond the Component Libraries...Developing Beyond the Component Libraries Users should not know they are using a Java application. Users approach the computer as a tool

Code Demo

Creating Novel Components

JavaOne 201056

Page 57: Developing Beyond the Component Libraries...Developing Beyond the Component Libraries Users should not know they are using a Java application. Users approach the computer as a tool

Agenda

❖ Why write a custom component?❖ Implementing a custom component❖ Introduction to Java’s L&F❖ Changing Swing’s appearance❖ Creating novel components❖ Understanding editor integration❖ Mashing Swing and JavaFX

JavaOne 201057

Page 58: Developing Beyond the Component Libraries...Developing Beyond the Component Libraries Users should not know they are using a Java application. Users approach the computer as a tool

Understanding Editor Integration

Why editor integrations?❖ Manually writing swing code is time consuming.❖ Many good editors for constructing Swing interfaces.❖ Have you ever tried maintaining code like this?

JavaOne 201058

Page 59: Developing Beyond the Component Libraries...Developing Beyond the Component Libraries Users should not know they are using a Java application. Users approach the computer as a tool

❖ Supporting editors such as NetBeans:

❖ Create BeanInfo objects for each component.

❖ Each component property should support PropertyChangeEvents (Beans Bindings).

❖ Include an icon representing the component.

❖ Support serialization.

Understanding Editor Integration

JavaOne 201059

Page 60: Developing Beyond the Component Libraries...Developing Beyond the Component Libraries Users should not know they are using a Java application. Users approach the computer as a tool

Understanding Editor IntegrationAdding SwingX widgets to NetBeans.

JavaOne 201060

Page 61: Developing Beyond the Component Libraries...Developing Beyond the Component Libraries Users should not know they are using a Java application. Users approach the computer as a tool

❖ Why write a custom component?❖ Implementing a custom component❖ Introduction to Java’s L&F❖ Extending components❖ Creating novel components❖ Understanding editor integration❖ Mashing Swing and JavaFX

Agenda

JavaOne 201061

Page 62: Developing Beyond the Component Libraries...Developing Beyond the Component Libraries Users should not know they are using a Java application. Users approach the computer as a tool

❖ Why JavaFX vs. Swing?❖ Scene graph❖ Integration with Photoshop/Illustrator❖ Skin controls with CSS❖ Rich media support❖ JavaFX 1.3 added lots of controls.

❖ Why Swing vs JavaFX?❖ Rich component libraries❖ Support native Look And Feels

❖ Why mix JavaFX and Swing?❖ Get the best of both worlds!

Mashing Swing and JavaFX

These are just a few reasons!

?JavaOne 2010

62

Page 63: Developing Beyond the Component Libraries...Developing Beyond the Component Libraries Users should not know they are using a Java application. Users approach the computer as a tool

Mashing Swing and JavaFX

Code Demo

Using JavaFX with Swing

JavaOne 201063

Page 64: Developing Beyond the Component Libraries...Developing Beyond the Component Libraries Users should not know they are using a Java application. Users approach the computer as a tool

❖ How to start writing components:❖ Browse the source to Java Swing library (src.jar).❖ Excellent open source projects (read/debug):

❖ SwingX (https://swingx.dev.java.net/)❖ JIID Software Open Layer (http://www.jidesoft.com/)

❖ Tools:❖ Java Decompiler (http://java.decompiler.free.fr/)

❖ Links:❖ http://www.l2fprod.com (Look & Fool)❖ http://today.java.net/article/2007/02/19/how-write-

custom-swing-component

Starting Points

JavaOne 201064

Page 65: Developing Beyond the Component Libraries...Developing Beyond the Component Libraries Users should not know they are using a Java application. Users approach the computer as a tool

Reference MaterialFurther Reading:

❖ Core Swing Advanced Programming by Kim Topley (0130832928)

❖ Filthy Rich Clients by Chet Hasse/Romain Guy (0-13-241393-0)

❖ JavaFX in Action by Simon Morris (1-933988-99-1)

JavaOne 201065

Page 66: Developing Beyond the Component Libraries...Developing Beyond the Component Libraries Users should not know they are using a Java application. Users approach the computer as a tool

Recap component development:

❖ ComponentUI - renders a component.

❖ JComponent - delegates rendering to its ComponentUI.

❖ ComponentUIs are looked up via the UIManager.

❖ Components can be customized via UIDefaults

Summary

JavaOne 201066

Page 67: Developing Beyond the Component Libraries...Developing Beyond the Component Libraries Users should not know they are using a Java application. Users approach the computer as a tool

❖ Don’t reinvent the wheel!

❖ Test on multiple platforms.

❖ Write a test harness to verify:

❖ Changing Locale

❖ Changing Look and Feel

❖ Enabling/disabling programmatically

Summary

JavaOne 201067

Page 68: Developing Beyond the Component Libraries...Developing Beyond the Component Libraries Users should not know they are using a Java application. Users approach the computer as a tool

Q&ACode samples/slides: www.cuprak.netQuestions: [email protected]

JavaOne 201068