Saldin Samuel eBay India Product Center 29 th October 2010.

Slides:



Advertisements
Similar presentations
15 Copyright © 2005, Oracle. All rights reserved. Adding User Interface Components and Event Handling.
Advertisements

Short introduction to the use of PEARL General properties First tier assessments Higher tier assessments Before looking at first and higher tier assessments,
Java Graphical User Interface (GUI) using Visual Editor in eclipse CSI 1390 – Java Programming Instructor: Saeid Nourian University.
Graphic User Interfaces Layout Managers Event Handling.
Intro to Threading CS221 – 4/20/09. What we’ll cover today Finish the DOTS program Introduction to threads and multi-threading.
1 Chapter 7 Graphics and Event Handling. 2 Overview The java.awt and javax.swing packages and their subpackages support graphics and event handling. Many.
Java Programming, 3e Concepts and Techniques Chapter 5 Arrays, Loops, and Layout Managers Using External Classes.
Lecture 24 Applets. Introduction to Applets Applets should NOT have main method but rather init, stop, paint etc They should be run through javac compiler.
Graphical User Interfaces (GUIs) GUI: An application that uses graphical objects to interact with users GUI applications consist of: –Events: A user or.
1 GUI Elements in Java Nelson Padua-Perez Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
Chapter 13: Advanced GUIs and Graphics J ava P rogramming: From Problem Analysis to Program Design, From Problem Analysis to Program Design, Second Edition.
1 Standard Widget Toolkit. 2 SWT l a widget toolkit for Java developers l provides a portable API and tight integration with the underlying native OS.
Fundamentals of Programming in Visual Basic 3.1 Visual basic Objects Visual Basic programs display a Windows style screen (called a form) with boxes into.
SE320: Introduction to Computer Games Week 8: Game Programming Gazihan Alankus.
PROGRAMMING REVIEW Lab 2 EECS 448 Dr Fengjun Li and Meenakshi Mishra.
Creating of Rich Client Applications using NetBeans 6 and Java Swing Miroslav Nachev.
Applets  The Applet Class  The HTML Tag F Passing Parameters to Applets.
Sikuli Ivailo Dinkov QA Engineer PhoneX Team Telerik QA Academy.
Chapter 13 Advanced GUIs and Graphics. Chapter Objectives Learn about applets Explore the class Graphics Learn about the class Font Explore the class.
Software Construction Lecture 10 Frameworks
Capture and Replay Often used for regression test development –Tool used to capture interactions with the system under test. –Inputs must be captured;
Introduction to Matlab & Data Analysis
Java Programming: From Problem Analysis to Program Design, 4e Chapter 12 Advanced GUIs and Graphics.
Automated GUI testing How to test an interactive application automatically?
Using the Netbeans GUI Builder. The Netbeans IDE provides a utility called the GUI Builder that assists you with creating Windows applications. The Netbeans.
Chapter 17: Applets, Images, and Sound. Objectives Learn about applets Write an HTML document to host an applet Use the init() method Work with JApplet.
Object Oriented Programming Ders 11: Interfaces Mustafa Emre İlal
3461A Readings from the Swing Tutorial. 3461A Overview  The follow is the Table of Contents from the trail “Creating a GUI with JFC/Swing” in the “The.
Java Event Handling CSIS 3701: Advanced Object Oriented Programming.
Oracle Data Integrator Procedures, Advanced Workflows.
GUIs in Java Swing, Events CS2110, SW Development Methods Readings: MSD, Chapter 12 Lab Exercise.
Graphics in Java Starring: NetBeans Co-Starring: Java.awt.
1 CSC111H Graphical User Interfaces (GUIs) Introduction GUIs in Java Understanding Events A Simple Application The Containment Hierarchy Layout Managers.
Graphic User Interface. Graphic User Interface (GUI) Most of us interact with computers using GUIs. GUIs are visual representations of the actions you.
Automated GUI testing How to test an interactive application automatically?
SWING 101. IF YOU GET LOST - IMPORTANT LINKS  Swing articles:
Java Applets: GUI Components, Events, Etc. Ralph Westfall June, 2010.
GUI Programming using NetBeans. RHS – SOC 2 GUI construction We have previously talked about elements in a (simple) GUI –Frames, Panes and Dialogs –Text.
Object-Oriented Program Development Using Java: A Class-Centered Approach, Enhanced Edition.
Lec.10 (Chapter 8 & 9) GUI Jiang (Jen) ZHENG June 27 th, 2005.
CS-1020 Dr. Mark L. Hornick 1 Event-Driven Programming.
Chapter 14 Applets and Advanced GUI  The Applet Class  The HTML Tag F Passing Parameters to Applets F Conversions Between Applications and Applets F.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 6 – Graphical User Interfaces Java Foundations: Introduction to Programming.
Swinging in Your Java Playground. Background Swing is a part of the Java Foundation Classes (JFC). The JFC is made up of features intended to give a programmer.
Swing - 2 Session 13. Swing - 2 / 2 of 38 Objectives (1) Discuss trees and tables Discuss progress bars Discuss MVC architecture Describe menus.
 In the java programming language, a keyword is one of 50 reserved words which have a predefined meaning in the language; because of this,
Sadegh Aliakbary Sharif University of Technology Fall 2011.
Chapter 14: Introduction to Swing Components. Objectives Understand Swing components Use the JFrame class Use the JLabel class Use a layout manager Extend.
Chapter 10 - Writing Graphical User Interfaces1 Chapter 10 Writing Graphical User Interfaces.
Lesson 28: More on the GUI button, frame and actions.
MATLAB and SimulinkLecture 61 To days Outline Graphical User Interface (GUI) Exercise on this days topics.
Developing GUIs With the Eclipse Visual Editor, Swing/AWT Edition David Gallardo.
Java Threads 1 1 Threading and Concurrent Programming in Java Threads and Swing D.W. Denbo.
CIS 270—Application Development II Chapter 11—GUI Components: Part I.
1 A Quick Java Swing Tutorial. 2 Introduction Swing – A set of GUI classes –Part of the Java's standard library –Much better than the previous library:
Java Programming Fifth Edition Chapter 13 Introduction to Swing Components.
Java Visual Applications CSIS 3701: Advanced Object Oriented Programming.
Beans Binding Framework & Swing Application Framework Geertjan Wielenga http//netbeans.dzone.com.
Swing Application Framework and Beans Binding David Botterill
Presenter Name This presentation introduces Swing Application Framework and Beans Binding JSRs. These are two new JSRs which greatly.
“Form Ever Follows Function” Louis Henri Sullivan
Lecture 27 Creating Custom GUIs
Lecture 28 Concurrent, Responsive GUIs
Ellen Walker Hiram College
Chapter 13: Advanced GUIs and Graphics
A Quick Java Swing Tutorial
Advanced Programming in Java
Constructors, GUI’s(Using Swing) and ActionListner
Advanced GUIs and Graphics
Presentation transcript:

Saldin Samuel eBay India Product Center 29 th October 2010

Saldin Samuel eBay India Product Center 29 th October 2010

 The Problem  Goals  Architecture  Using Swing Application Framework

 The Problem  Goals  Architecture  Using Swing Application Framework

 Jillions of Swing Apps without a Standard Desktop Application Framework developed over a decade  Same core elements for application life cycle – New applications create core elements from scratch  Developers freeze on Structuring Applications  Forced to focus on Application Architecture rather than Solving Problems  Not great User Experience on building apps from scratch  High Learning Curve for novices

 Lack of standardization of development: ◦ ABP 1: Build application on main thread ◦ ABP 2: Consider application is a JFrame ◦ ABP 3: Tangle of actionPerformed methods block EDT  Lack of Tooling Support for Desktop Applications  Too much frame but not enough work ◦ Over Design ◦ Try and Do too much ◦ A shrine for great hacks

 The Problem  Goals  Architecture  Using Swing Application Framework

 Provide Kernel To Typical Swing Application  Help Programmers to Get Started Quickly  Adopt Best Practices for following elements: ◦ Architecture ◦ Life Cycle ◦ Resource Management ◦ Event Handling ◦ Threading ◦ Session State ◦ Local Storage

 The Problem  Goals  Architecture  Using Swing Application Framework

Application ApplicationContext ResourceManager ResourceMap ActionManager ApplicationActionMap TaskService Task TaskMonitor SessionStorage LocalStorage

 Application Class  Resources  Actions  Tasks  Sessions

 Application Class  Resources  Actions  Tasks  Sessions

launchinitializestartupreadyexitshutdown StateLife Cycle Mandatory Optional Overridden Overridden

launchinitializestartupreadyexitshutdown Call shutdown, if the exitListeners don't veto. Main frame’s WindowListener calls exit(). Calls initialize(), startup() and ready() on the EDT. A static method, usually called from main(). Take the GUI down, final cleanup. Any work that must wait until the GUI is visible and ready for input. Performs initializations that must happen before the GUI is created, like setting the look and feel. Create the initial GUI and show it. All applications will override this method.

ApplicationSingleFrameApplicationMultiFrameApplicationAnything else ….

 Application Class  Resources  Actions  Tasks  Sessions

 Based on ResourceBundle  Organized in resources subpackages  Initialize properties ◦ Look and Feel ◦ Locale ◦ Platform

 Initial, read-only values  Based on String  Defined in.properties files

 Automatically parent-chained ◦ package-wide resources ◦ application-wide resources  Names based on a class: ◦ Generic Resource bundle – just a class name ◦ OS specific – class_os  Support string to type resource conversion  Localizable by default  No need to explicitly lookup/set resources  Easy to reconfigure and review visual app properties  Not a “style” mechanism and Not for GUI Markup

 ResourceMap.injectComponents() ◦ Set the properties of named components ◦ Convert types as needed # resources/MyPanel.properties label.text = Choose one: label.font = Lucida-PLAIN-18 button1.icon = smiley.gif button2.icon = scared.gif button3.icon = sad.gif component.getName(): label button1 button2 button3

 Application Class  Resources  Actions  Tasks  Sessions

 Implementation // define sayHello Action – pops up a message Dialog Action sayHello = new AbstractAction("Hello") { public void actionPerformed(ActionEvent e) { String s = textField.getText(); JOptionPane.showMessageDialog(s); } }; // use sayHello – set the action property textField.setAction(sayHello); button.setAction(sayHello);  Pain Points ◦ Pain in Creating Action Objects ◦ Asynchronous Actions are difficult ◦ Visual Properties should be localized

 Implementation // define sayHello Action – pops up a message public void sayHello() { String s = textField.getText(); JOptionPane.showMessageDialog(s); } // use sayHello – set the action property Action sayHello = getAction("sayHello"); textField.setAction(sayHello); button.setAction(sayHello);  Key Points ◦ ActionEvent argument is optional ◦ public methods only ◦ Used to define a “sayHello” ActionMap entry

 Implementation // private utility method: look up an action for this class Action getAction(String name) { ApplicationContext c = ApplicationContext.getInstance(); ActionMap actionMap = c.getActionMap(getClass(), this); return actionMap.get(name); }  ApplicationContext.getActionMap() ◦ Creates an Action for method ◦ Default key is the action's method name ◦ Creates and caches an ActionMap

 Loaded from the class's ResourceMap  Component's action property can be Injected # resources/MyForm.properties sayHello.Action.text = Say &Hello sayHello.Action.icon = hello.png sayHello.Action.accelerator = control H sayHello.Action.shortDescription = Say hello modally textField.action = sayHello button.action = sayHello

# resources/MyForm.properties sayHello.Action.text = Say Hello sayHello.Action.icon = hello.png button1.action = sayHello button2.action = sayHello button2.text = ${null} button3.action = sayHello button3.icon = ${null} button1 button2 button3

 Application Class  Resources  Actions  Tasks  Sessions

  Task -> SwingWorker -> Future ◦ Futures compute a value on thread ◦ Support for start, stop and monitor ◦ Can be cancelled/interrupted  SwingWorker Adds ◦ done() and PropertyChange() methods for EDT ◦ Publish/process for incremental results  More support more Monitoring

 Defines how a Task is executed ◦ Serially, by a thread pool, etc.  ExecutorService ◦ named, constructed lazily = “database”)  Application.getTaskServices()

 Desktop apps often run many threads  TaskMonitor provides a summary ◦ Bound properties, same as Task ◦ Foreground task: first one started  Handy for StatusBar implementations

 Application Class  Resources  Actions  Tasks  Sessions

 Make sure the application remembers ◦ where you left things.  Most applications should do this ◦ but they don't ◦ what state to save? ◦ where to store it (and what if you're unsigned)? ◦ how to safely restore the GUI

 ApplicationContext.getSessionStorage() ◦ save(rootComponent, filename)  Supported types, named components only  Window bounds, JTable column widths, etc  Archived with XMLEncoder ◦ restore(rootComponent, filename)  conservative  restored with XMLDecoder  LocalStorage abstracts per-user files

Saldin Samuel eBay India Product Center 29 th October 2010

 About FEST  FEST for Swing GUI Automation  Demo

 Fixtures for Easy Software Testing  Collection of open source API  Supports both JUnit and TestNG  Composed of various modules: ◦ Swing ◦ Assertions ◦ Reflection ◦ Mocks

 Fixtures for Easy Software Testing  Collection of open source API  Supports both JUnit and TestNG  Composed of various modules: ◦ Swing ◦ Assertions ◦ Reflection ◦ Mocks

 Fluent Interface for functional swing GUI testing  Easy to use  Features ◦ Simulation of User Interface ◦ Reliable Component Lookup ◦ Complete support of all component ◦ Support for regular expression ◦ Supports Applet Testing ◦ Screenshot on failure ◦ Threading Rules Violations

 Uses AWT Robot to generate input ◦ Capable of generating native events ◦ Most accurate simulation of actual user  Capabilities includes simulation for: ◦ Editing JTable cells  JCheckBox, JcomboBox, JTextField ◦ Drag and Drop  Screen co-cordinates  Swing Components  Special implementations for JList, JTable, JTree ◦ Key board events ◦ Mouse Input

 Common Component Matchers ◦ By name, title/text or visibility  Dialog, Frame, Button, Label, JTextComponent  Performing GUI Component Lookup ◦ Looking up Components with ComponentFinder ◦ Using a ContainerFixture to Look Up Components  Testing Long-Duration Tasks ◦ WindowFinder, JOptionPaneFinder, JFileChooserFinder

 Uses AWT Robot to generate input ◦ Capable of generating native events ◦ Most accurate simulation of actual user  Capabilities includes simulation for: ◦ Editing JTable cells  JCheckBox, JcomboBox, JTextField ◦ Drag and Drop  Screen co-cordinates  Swing Components  Special implementations for JList, JTable, JTree ◦ Key board events ◦ Mouse Input

 Provides its own Applet Viewer  Testing involves start, test and cleanup  Start using AppletLauncher ◦ By name, By class or By instantiating a class ◦ With parameters  Supports to start Applet directly  Cleanup – unloadApplet()

 Manually ◦ ScreenshotTaker captures and saves as png  Supports JUnit and TestNG GUI test failures

 FailOnThreadViolationRepainManager forces failure is component access not thru EDT  Simple to public void setUpOnce() { FailOnThreadViolationRepaintManager.install(); }

 Fluent interface for writing assertions  Improved test code readability and easy maintenance  Supports following data types: ◦ Object ◦ String ◦ Collection ◦ Map ◦ Primitives (boolean, int, char, etc.) ◦ Arrays of Object ◦ Arrays of primitives ◦ BufferedImage ◦ Throwable ◦ File ◦ BigDecimal