Writing High-Performance Applications With the Java™ Foundation Classes (JFC/Swing) API

Steve Wilson
Java Performance Engineering
Sun Microsystems


Introduction


Presentation Goal


Overview


The Book


What Is Performance?


Performance Process Diagram


Profiling Tools


Commercial Profiling Tools


Tactics Overview


Object Allocation Costs


Returned Copies


MVC and Performance


JFC/Swing API’s Model/Renderer System


Loading a ComboBox


JComboBox: Try #1


JComboBox: Try #2


Prototype Cells


Prototype Cell Example


Prototype Cell Performance

Time to display Component with 10,000 items in
milliseconds on 866 MHz PC
Small numbers are good


TableModel and Footprint


Big Model (Simple)


Big Model (Sparse)


JFC/Swing APIs Default Models


Multi-threaded GUIs


Responsiveness


JFC/Swing API and Threading


JFC/Swing API’s Thread Model


Single Thread Rule


Exceptions to the Rule


When to Use Threads?


Long Tasks


Example #1: DB Query


Example #2: Better Query


Using SwingWorker


Repetitive Actions


Use javax.swing.Timer


Deployment


“Java Archives”


Sticky JARs


Java™ Web Start Software


Volatile Image—New for 1.4


Summary