Swinging from the Outside

Similar documents
Graphical User Interfaces (GUIs)

Preface. WELCOME to Filthy Rich Clients. This book is about building better, more. Organization

Filthy Rich Clients: Filthier. Richer. Clientier. Romain Guy, Google Chet Haase, Adobe Systems

Advanced Effects in Java Desktop Applications

Rich Client GUI's with RCP & RAP

Bringing Life to Swing Desktop Applications

Java FX. Threads, Workers and Tasks

Seng310 Lecture 8. Prototyping

LAB-6340: Advanced Java ME Programming - Streaming Video From Server to Your Device

GUI Programming. Chapter. A Fresh Graduate s Guide to Software Development Tools and Technologies

Creating Professional Swing UIs Using the NetBeans GUI Builder

NASA World Wind Java SDK

LIGHTWEIGHT UI TOOLKIT MAKING COMPELLING JAVA ME APPLICATIONS EASY

Radical GUI Makeover with Ajax Mashup

Developing LimeWire: Swing for the Masses

Low fidelity: omits details High fidelity: more like finished product. Breadth: % of features covered. Depth: degree of functionality

Lesson 3 Transcript: Part 1 of 2 - Tools & Scripting

WindowBuilder Graduation & Release Review

Heavyweight with platform-specific widgets. AWT applications were limited to commonfunctionality that existed on all platforms.

Java Swing Introduction

Web 2.0: Next Generation Communities With Rich Java -Based Applications

Simplifying Development and Testing of GUIs with SAF (JSR 296) and FEST. Michael Hüttermann Training & Consulting Alex Ruiz Oracle Corporation

Swing and you are winning

Java.net - the Source for Java(tm) Technology Collaboration

Two geeks discuss Mobile/RIA stuff over coffee

CS3205 HCI IN SOFTWARE DEVELOPMENT PROTOTYPING STRATEGIES. Tom Horton. * Material from: Floryan (UVa) Klemmer (UCSD, was at Stanford)

Prototyping. Readings: Dix et al: Chapter 5.8 Marc Rettig: Prototyping for tiny fingers, Communications of the ACM, April 1994.

JavaServer Faces Technology, AJAX, and Portlets: It s Easy if You Know How!

mismatch between what is maybe possible today and what is going on in many of today's IDEs.

Java FX 2.0. Dr. Stefan Schneider Oracle Deutschland Walldorf-Baden

Improve and Expand JavaServer Faces Technology with JBoss Seam

CSE 331 Software Design & Implementation

Lecture 6. Design (3) CENG 412-Human Factors in Engineering May

Page 1. Human-computer interaction. Lecture 1b: Design & Implementation. Building user interfaces. Mental & implementation models

MemoryLint. Petr Nejedlý, Radim Kubacki SUN Microsystems, BOF-9066

Page 1. Human-computer interaction. Lecture 2: Design & Implementation. Building user interfaces. Users and limitations

AUTOMATED HEAPDUMP ANALYSIS FOR DEVELOPERS, TESTERS, AND SUPPORT EMPLOYEES

Lesson 8 Transcript: Database Security

JDirectoryChooser Documentation

Widget Toolkits CS MVC

CaptainCasa Enterprise Client. Why, where, how JavaFX makes sense

Speech 2 Part 2 Transcript: The role of DB2 in Web 2.0 and in the IOD World

Lab Guide. Service Portal and Mobile. Patrick Wilson & Will Lisac. Default Login / Password: admin / Knowledge17. itil / Knowledge17

Petr Suchomel Architect, NetBeans Mobility

Copyright 2013, Oracle and/or its affiliates. All rights reserved.

Page 1. Ideas to windows. Lecture 7: Prototyping & Evaluation. Levels of prototyping. Progressive refinement

CS211 Lecture: The User Interface

<Insert Picture Here> JavaFX 2.0

The COS 333 Project. Robert M. Dondero, Ph.D. Princeton University

Developing applications using JavaFX

Human-Computer Interaction IS4300

CS 4300 Computer Graphics

Java Programming Constructs Java Programming 2 Lesson 1

Midterm Reminders. Design Pattern #6: Facade. General Idea. The Situation

Lecture Topics. Administrivia

How NikeiD Hurdled the Java Technology and Flash Barrier

Intro to Java Programming, Comprehensive Version, Global Edition

Widget. Widget is a generic name for parts of an interface that have their own behaviour. e.g., buttons, progress bars, sliders, drop-down

Introduction to Graphical Interface Programming in Java. Introduction to AWT and Swing

Multiple Inheritance, Abstract Classes, Interfaces

Canvas. Walter Goodwater, Software Development Manager

Thread Safety. Review. Today o Confinement o Threadsafe datatypes Required reading. Concurrency Wrapper Collections

CPS122 Lecture: The User Interface

A Design Recovery View - JFace vs. SWT. Abstract

8.3 cloud roadmap. Dr. Andrei Borshchev, CEO Nikolay Churkov, Head of Software Development. The AnyLogic Company Conference 2018 Baltimore

BUILDING DATABASE SYSTEMS (X478)

GUI Event Handlers (Part I)

1 Build Your First App. The way to get started is to quit talking and begin doing. Walt Disney

Fall UI Design and Implementation 1

Monkeybars Tools-enabled Swing development with JRuby

Tcl/Tk lecture. What is the Wish Interpreter? CIS 410/510 User Interface Programming

Graphical User Interface (GUI)

Adapter. Comp-304 : Adapter Lecture 23. Alexandre Denault Computer Science McGill University Fall 2007

User Interfaces in LabVIEW

CORE JAVA TRAINING COURSE CONTENT

Windows and Events. created originally by Brian Bailey

Quality Assurance User Interface Modeling

Creating accessible forms

CoSc Lab # 5 (The Controller)

I m going to be introducing you to ergonomics More specifically ergonomics in terms of designing touch interfaces for mobile devices I m going to be

Prezi Quick Guide: Make a Prezi in minutes

Human Computer Interface Design Chapter 7 User Interface Elements Design and Guidelines

Clickbank Domination Presents. A case study by Devin Zander. A look into how absolutely easy internet marketing is. Money Mindset Page 1

BCSWomen Android programming (with AppInventor) Family fun day World record attempt

JSR 377 Desktop Application Framework September Andres Almiray

Test Patterns in Java

CS108, Stanford Handout #22. Thread 3 GUI

Building a Java ME Test Suite in 15 Minutes

Introduction to the NetBeans Platform Certified Training Course. Geertjan Wielenga Sun Microsystems

CPS221 Lecture: Threads

the gamedesigninitiative at cornell university Lecture 13 Architecture Design

C15: JavaFX: Styling, FXML, and MVC

Introduction to GUIs. Principles of Software Construction: Objects, Design, and Concurrency. Jonathan Aldrich and Charlie Garrod Fall 2014

CS11 Java. Fall Lecture 4

CS 116x Winter 2015 Craig S. Kaplan. Module 03 Graphical User Interfaces. Topics

15-Minute Fix: A Step-by-Step Guide to Designing Beautiful Dashboards

GWT and jmaki: Expanding the GWT Universe. Carla Mott, Staff Engineer, Sun Microsystems Greg Murray, Ajax Architect, Sun Microsystems

AD105 Introduction to Application Development for the IBM Workplace Managed Client

Introduction to Concurrent Software Systems. CSCI 5828: Foundations of Software Engineering Lecture 08 09/17/2015

Preventing Errors Help and Documentation

Transcription:

Swinging from the Outside A guide to navigating Swing from the outside of Sun Brian Mason, Dir Software of Engineering, Teseda S295599

Space is big, really big. You might think it is a long way down to the chemist's, but that is peanuts to space. Swing toolkit, however, isn't that big, but it is still pretty big. Starting out it can be confusing. Understanding common issues and finding solutions is a key to successfully navigating Swing toolkit. By the end of this presentation, you will have an idea of the issues and a direction to start creating cool Swing Applications 2008 JavaOne SM Conference java.sun.com/javaone 2

A quick search of some Swing toolkit helpers Swing Java 2D JOGL Java 3D JSR-295 SwingX Java FX SWT JDIC JChart JSR-295 JBuilder JGoodies JXLayers Netbeans InteliJ ILOG Eclipse Timing Framework 2008 JavaOne SM Conference java.sun.com/javaone 3

Why Would a New Swing toolkit Developer be Confused? 2008 JavaOne SM Conference java.sun.com/javaone 4

Agenda Classification of Swing Applications Application Frameworks Threading and Task Management Making the User Wait Making it pretty Q&A 2008 JavaOne SM Conference java.sun.com/javaone 5

Classification of Swing Applications Purpose of classification is to understand what is important Focus discussion Recognize not all applications need the same things Classification is basically understanding the user Many other parameters go into user understanding besides target use Two broad classifications of Swing Apps are: Consumer Applications Business Applications 2008 JavaOne SM Conference java.sun.com/javaone 6

Business Applications Maybe Mission Critical Often set UI guidelines, Used All day Skinning not needed (or desired) Use of Animation and colors often controlled Needs to be very stable UI Must minimize eye strain I18N always a good idea, but localization often not needed Apps often not run as admin Example, OC UI Guidelines 2008 JavaOne SM Conference java.sun.com/javaone 7

Consumer Applications Less formal UI More Glitz allowed/expected Maybe used for shorter periods of time Varied user base. I18N and L10N very important Personalization such as Skins, important Often app is run as Admin on windows 2008 JavaOne SM Conference java.sun.com/javaone 8

Agenda Classification of Swing Applications Application Frameworks Threading and Task Management Making the User Wait Making it pretty Q&A 2008 JavaOne SM Conference java.sun.com/javaone 9

Application Framework Definition from Wikipedia: A software framework is a re-usable design for a software system (or subsystem) A Guideline/best practices and set of helper classes to build an application We are not talking about frameworks for: Animation UI Handling RDBMS Access An application framework is for the whole application, not small, yet important parts. Component Libraries are not frameworks 2008 JavaOne SM Conference java.sun.com/javaone 10

Qualities of Good Application Frameworks SIMPLE, SIMPLE and SIMPLE Is not intrusive, can be used or not (At the same time) Helps With Resource Management Thread Management Life Cycle Has a Standard Look and Feel? Same on all platforms? Matches Platform? Allows for Branding / Matching Corp UI standards If it is just as hard to develop the app with the framework as without, then it hasn't saved you any work (J. Murphy) 2008 JavaOne SM Conference java.sun.com/javaone 11

Example of Bad A framework requires all Windows derived from a base class Does everything a Special Way Does not allow components to move between applications Resources are stored centrally Functionality is tied to a named class Think MFC 2008 JavaOne SM Conference java.sun.com/javaone 12

Example Application Frameworks Great Frameworks we will not discuss The Brian Framework The John Framework The great unified Framework Cool looking Frameworks Swing Application Framework (Java Specification Request 296) Jmatter Starter Code from IDE 2008 JavaOne SM Conference java.sun.com/javaone 13

The Swing Framework (JSR-296), How does it line up? Does it meet the test Is it Simple? Does it stay out of your way? Helps With Resource Management Thread Management Life Cycle Has a Standard Look and Feel? Hold the thought. Lets Look at the Demo!!! 2008 JavaOne SM Conference java.sun.com/javaone 14

Simple JSR-296 Application 2008 JavaOne SM Conference java.sun.com/javaone 15

Advice for all Frameworks, libraries,blogs and books Double Check Everything Learn Basic Swing Toolkit Rules Do not assume things are correct If code uses threads, double check it again Check the code into Source Control Check Threading! Threading errors in book code Use Static Analysis for Threading. 2008 JavaOne SM Conference java.sun.com/javaone 16

Agenda Classification of Swing Applications Application Frameworks Threading and Task Management Making the User Wait Making it pretty Q&A 2008 JavaOne SM Conference java.sun.com/javaone 17

Embrace the Horror You cannot avoid multi-threaded Swing tookit Event Dispatch Thread (EDT) Do not block the EDT; EVER File System Access Network Access DB Access Even long memory based task, like sorting Swing Calls, unless specifically document otherwise, must be ON the EDT 2008 JavaOne SM Conference java.sun.com/javaone 18

Bad Threading Example (EDT Handler) Jlist filelist=new JList(); File dir=new File("."); File[] list=dir.listfiles(); DefaultListModel model=new DefaultListModel(); for(file f:list){ model.addelement(f.getname()); } filelist.setmodel(model); 2008 JavaOne SM Conference java.sun.com/javaone 19

Perfuming the hog (Threaded Handler) Runnable run = new Runnable() { public void run() { File dir = new File("."); File[] list = dir.listfiles(); DefaultListModel model = new DefaultListModel(); for (File f : list) { model.addelement(f.getname()); } filelist.setmodel(model);} }; Thread t=new Thread(run); t.start(); 2008 JavaOne SM Conference java.sun.com/javaone 20

Legal Thread Solution Runnable run = new Runnable() { public void run() { File dir = new File("."); File[] list = dir.listfiles(); DefaultListModel model = new DefaultListModel(); for (File f : list) { model.addelement(f.getname()); } loadthemodelsafely(model)} }; ExecutorService background=somefactory.getbackgroundexec() background.submit(run); 2008 JavaOne SM Conference java.sun.com/javaone 21

Legal Thread Solution Slide 2 void loadthemodelsafely(final ListModel model){ Runnable run=new Runnable(){ public void run(){ list.setmodel(model); } } } if(swingutilities.iseventdispatchthread()){ run.run(); }else{ //try catch block ommitted for readability SwingUtilities.invokeAndWait(run); } 2008 JavaOne SM Conference java.sun.com/javaone 22

Actions Meets Swing Worker A humble example of cleaner solution for blocking task Like Swing Worker but ties to actions Uses Swing Utils and threading behind the scene Has three abstract methods: preuiwork backgroundwork postuiwork 2008 JavaOne SM Conference java.sun.com/javaone 23

Threaded Actions Example class BlockingButtonAction extends BlockingAction{ public void preuiwork(actionevent e) { parent.setglasspane(gp); gp.setvisible(true);} public Object backgroundwork(actionevent e){ Thread.sleep(20000); return null;} public void postuiwork(actionevent e,object resultsfrombackground, Throwable error) { gp.setvisible(false); } 2008 JavaOne SM Conference java.sun.com/javaone 24

Threaded Actions 2008 JavaOne SM Conference java.sun.com/javaone 25

JSR-296 Actions Actions defined by @Action annotation on methods Must Bind Action to Components Handles Blocking and non-blocking actions Reporting method built in 2008 JavaOne SM Conference java.sun.com/javaone 26

JSR-296 Actions 2008 JavaOne SM Conference java.sun.com/javaone 27

Agenda Classification of Swing Applications Application Frameworks Threading and Task Management Making the User Wait Making it pretty Q&A 2008 JavaOne SM Conference java.sun.com/javaone 28

Blocking The User It's OK, they need a coffee break Why is it so hard? Keyboard Mouse Letting the user know what's happening When and how should we block the User? Never Only With a modal Dialog With a Glass Pane How about just a wait cursor???? You can never truly block a user Give them a Cancel Option so they use Your Solution There is a close widget on the window There is always kill -9 2008 JavaOne SM Conference java.sun.com/javaone 29

Blocking Solutions 2008 JavaOne SM Conference java.sun.com/javaone 30

Agenda Classification of Swing Applications Application Frameworks Threading and Task Management Making the User Wait Making it pretty Q&A 2008 JavaOne SM Conference java.sun.com/javaone 31

Making it Pretty Pretty does not always mean fancy Beauty is in the Eye of the Beholder Business apps used all day need to be Easy On the Eyes Remember guidelines for business apps Embrace alternatives Embrace Java 2D API Swing Labs Third Party Libs 2008 JavaOne SM Conference java.sun.com/javaone 32

Java 2D API Swing is built on Java 2D API Paint methods take a Graphics2D as parameter The docs will show Graphics, cast it Rich set of methods for 2D work Well done and easy to use Can really speed up performance 2008 JavaOne SM Conference java.sun.com/javaone 33

Swing Labs http://www.swinglabs.org Collection of several libraries SwingX Timing Framework JDesktop Integration Components (JDIC) SwingX-WS and more... Code is lab code It does change Put your copy in Source Control 2008 JavaOne SM Conference java.sun.com/javaone 34

GUI Builders Should we use GUI Builders? Arguments Against Ugly Code Doesn't support what I need Arguments For Speed Not everyone is the UI god you (think you) are Prettier Code Some Examples Netbeans software Intelli-J Jbuilder 2008 JavaOne SM Conference java.sun.com/javaone 35

GUI Builder Use 4000 Surveyed (Mail List) 9 Responded 5 Used None GUI Builders Netbeans Borland IDEA Win Builder None 2008 JavaOne SM Conference java.sun.com/javaone 36

Resources Folks & Sites I stole reused code from Swing Hacks (9780596009076) Joshua Marinacci, Chris Adamson Alexander Potochkin's Blog http://weblogs.java.net/blog/alexfromsun/ Filthy Rich Clients Chet Haase and Romain Guy http://filthyrichclients.org/ http://community.java.net/javadesktop/ 2008 JavaOne SM Conference java.sun.com/javaone 37

Summary If you walk out with one message today: Swing is a great tool, there are lots of resources to help you You now have: A guideline for evaluating Frameworks and a example of a reasonable one A feel for some common issues in Swing Development A list of good resources to go and learn/try more 2008 JavaOne SM Conference java.sun.com/javaone 38

Brian Mason, Dir Software Engineering. S295599 2008 JavaOne SM Conference java.sun.com/javaone 39