Developing GUIs With the Eclipse Visual Editor, Swing/AWT Edition David Gallardo.

Slides:



Advertisements
Similar presentations
Introduction to Java 2 Programming
Advertisements

15 Copyright © 2005, Oracle. All rights reserved. Adding User Interface Components and Event Handling.
Java Graphical User Interface (GUI) using Visual Editor in eclipse CSI 1390 – Java Programming Instructor: Saeid Nourian University.
Java Software Development Paradigm Lecture # 12. Basics of GUI.
Graphic User Interfaces Layout Managers Event Handling.
CMSC 341 Building Java GUIs. 09/26/2007 CMSC 341 GUI 2 Why Java GUI Development? Course is about Data Structures, not GUIs. We are giving you the opportunity.
Corresponds with Chapter 12
Fall 2007CS 225 Graphical User Interfaces Event Handling Appendix C.
Guide to Oracle10G1 Introduction To Forms Builder Chapter 5.
Chapter 6 Graphical User Interface (GUI) and Object-Oriented Design (OOD)
Java Swing Toolkit Graphics The key to effectively using graphics in Java is understanding: –the basic components of the graphics library –the patterns.
Understanding SWING Architecture CS 4170 UI Design Hrvoje Benko Oct. 9, 2001.
Lecture 15 Graphical User Interfaces (GUI’s). Objectives Provide a general set of concepts for GUI’s Layout manager GUI components GUI Design Guidelines.
A Guide to Oracle9i1 Introduction To Forms Builder Chapter 5.
Graphical User Interfaces (GUIs) GUI: An application that uses graphical objects to interact with users GUI applications consist of: –Events: A user or.
©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 4 th Ed Chapter Chapter 14 GUI and Event-Driven Programming.
Creating a GUI with Swing. Introduction Very useful link: Swing – is a part of JFC (Java Foundation.
1 GUI Elements in Java Nelson Padua-Perez Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
1 CMSC 132: Object-Oriented Programming II Nelson Padua-Perez William Pugh Department of Computer Science University of Maryland, College Park.
Scott Grissom, copyright 2006Ch 11: GUI Slide 1 Graphical User Interfaces (Ch 11) Careful design of a graphical user interface is key to a viable software.
CPSC150 Week 12 Graphical User Interfaces Chapter 11.
Contructing GUI’s in Java Implemented in the Swing API Imported into your programs by: import javax.swing.*; Most Swing programs also need the AWT packages.
Access Tutorial 10 Automating Tasks with Macros
PROGRAMMING REVIEW Lab 2 EECS 448 Dr Fengjun Li and Meenakshi Mishra.
GUI Basics: Introduction. Creating GUI Objects // Create a button with text OK JButton jbtOK = new JButton("OK"); // Create a label with text "Enter your.
Using the Netbeans GUI Builder. The Netbeans IDE provides a utility called the GUI Builder that assists you with creating Windows applications. The Netbeans.
Applets and Frames CS 21a: Introduction to Computing I First Semester,
Introduction to GUI in Java 1. Graphical User Interface Java is equipped with many powerful,easy to use GUI component such as input and output dialog.
Java GUIs and Graphics CNS Outline  Introduction  Events  Components  Layout managers  Drawing  Introduction  Events  Components  Layout.
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.
ICALEPCS, “jddd” a Java DOOCS Data Display for the XFEL Editor for a Graphical User Interface of DOOCS & TINE and Runtime Engine Elke Sombrowski.
Java Programming: Advanced Topics 1 Common Elements of Graphical User Interfaces Chapter 6.
Graphical User Interface Components Chapter What You Will Learn Text Areas Text Areas Sliders Sliders Menus Menus –With frames –Pop up menus Look.
Introducing the Eclipse Visual Editor David Gallardo.
Pasewark & Pasewark 1 Access Lesson 5 Creating and Modifying Reports Microsoft Office 2007: Introductory.
GUI development in Java L. Grewe Two methodologies for things to appear on the screen 1. By painting / drawing e.g. drawing an Image e.g. drawing an.
Ch 3-4: GUI Basics Java Software Solutions Foundations of Program Design Sixth Edition by Lewis & Loftus Coming up: GUI Components.
Graphic User Interface. Graphic User Interface (GUI) Most of us interact with computers using GUIs. GUIs are visual representations of the actions you.
Graphics and Event-Driven Programming in Java John C. Ramirez Department of Computer Science University of Pittsburgh.
1 Creating Windows GUIs with Visual Studio. 2 Creating the Project New Project Visual C++ Projects Windows Forms Application Give the Project a Name and.
Layout Manager Summary
Chapter 12Java: an Introduction to Computer Science & Programming - Walter Savitch 1 Announcements/Reminders l Next week: »No Lectures »No Labs »Recitation.
Applets and Frames. Copyright 2005, by the authors of these slides, and Ateneo de Manila University. All rights reserved L14: GUI Slide 2 Applets Usually.
The Abstract Window Toolkit (AWT) supports Graphical User Interface (GUI) programming. AWT features include: a rich set of user interface components; a.
CS1054: Lecture 21 - Graphical User Interface. Graphical User Interfaces vs. Text User Interface.
Introduction to GUI in 1 Graphical User Interface 2 Nouf Almunyif.
Pasewark & Pasewark 1 Access Lesson 5 Creating and Modifying Reports Microsoft Office 2007: Introductory.
GUIs Graphical User Interfaces. Everything coming together Known: – Inheritance – Interfaces – Abstract classes – Polymorphism – Exceptions New: – Events.
Introduction to Java Chapter 9 - Graphical User Interfaces and Applets1 Chapter 9 Graphical User Interfaces and Applets.
1 Chapter 16: Creating Windows. 2 Basics of GUI Programming How to create a Window. TryWindow.java You always need a JFrame component before creating.
Creating a Window. A basic window in Java is represented by an object of the class Window in the package java.awt.
Ajmer Singh PGT(IP) JAVA IDE Programming - I. Ajmer Singh PGT(IP) GUI (Graphical User Interface) It is an interface that uses a graphic entities along.
Java Programming, Second Edition Chapter Thirteen Understanding Swing Components.
Developing GUIs With the Eclipse Visual Editor, SWT Edition David Gallardo.
Chapter 10 - Writing Graphical User Interfaces1 Chapter 10 Writing Graphical User Interfaces.
Graphical User Interface (GUI)
User Interface Components. Layout Placement of UI components in a window – Size & Position Each component occupies a rectangular region in the window.
Applets. 9/04/2005 Copyright 2005, by the authors of these slides, and Ateneo de Manila University. All rights reserved L12: Applets Slide 2 Applets Usually.
Introduction to GUI in 1 Graphical User Interface 3 Nouf Almunyif.
Introduction to GUI Programming in Java: Frames, Simple Components, and Layouts.
CIS 270—Application Development II Chapter 11—GUI Components: Part I.
Java Programming Fifth Edition Chapter 13 Introduction to Swing Components.
Introduction to Swing Mr. Crone. What is Swing? a collection of pre-made Java classes used to create a modern graphical user interface.
Java GUI.
תכנות מכוון עצמים בשפת JAVA
Graphical User Interface
Steps to Creating a GUI Interface
Graphical User Interface
TA: Nouf Al-Harbi NoufNaief.net :::
Presentation transcript:

Developing GUIs With the Eclipse Visual Editor, Swing/AWT Edition David Gallardo

My books Java Oracle Database Development Eclipse in Action, (lead author) Eclipse in Action, 2 nd edition due out in December Preview article, Introducing the Eclipse Visual Editor, available at:

Presentation and source available at:

The Visual Editor is Eclipse’s long-awaited GUI Builder for Swing/AWT and SWT

What’s a GUI builder good for? Coding graphical user interfaces is tedious and requires verbose code Visualizing the effects of code and code changes isn’t intuitive for most people The flexible, powerful layouts that give professional results can be especially difficult to program A GUI builder lets you use graphical design tools in a WYSIWYG environment to design the GUI and generates code for you

The Eclipse Visual Editor It’s been a long time coming… –Difficult to develop –Hard to make one that generates good code and that doesn’t require proprietary artifacts like format files –Visual Age for Java had one of the few good ones –Little incentive for IBM to contribute this to Eclipse? The lack of a GUI build was one of the chief complaints about Eclipse, vis-à-vis competitors

Introducing the Eclipse Visual Editor IBM eventually relented and contributed their Visual Editor in Fall 2003 Initial version, 0.5, was Swing/AWT only Version 1.0, released Fall 2004, introduced limited SWT support Version 1.1, released July 2005, adds more SWT support and support for RCP views

Installing VE VE is an independent component that plugs into Eclipse JDT Install using Eclipse Update feature. This will install VE and the following dependencies: –Graphical Editing Framework (GEF) –Eclipse Modeling Framework (EMF) Versions of Eclipse, VE, GEF and EMF must be compatible—Update will make sure that dependency requirements are met

Principal VE features Wizard for creating Visual Classes—classes that extend Swing/AWT components Visual editor with palette of components and containers and two views in usual editor location: –Design view –Source view Java Beans View Properties View Indicator and tool buttons for controlling synchronization between views

Visual class wizard Swing options: –Applet –Application –Desktop panel –Dialog –Frame –Internal Frame –Panel –Scroll Pane –Split pane –Tabbed Pane –Window AWT options: –Applet –Dialog –Frame –Panel –Scroll Pane –Window

Swing/AWT palette selections The VE palette organizes Swing/AWT components in folders: Swing components: JButtons, JCheckBox, JLabel… Swing containers: JFrame, JPanel, JScrollPane… Swing menus: JMenuBar, JMenuItem, JToolBar… AWT Controls:Frame, Dialog, Button, Label…

Working with components Drag and drop from palette to design view or Java Beans view Adjust size or position in design view (if layout manager permits) Modify properties in Properties View Add event handlers in design view or Java Beans view Modify source directly By default, changes in one view will be reflected automatically in the rest Synchronization can be turned off or on with toolbutton; indicator appears in status bar

Working with layouts If you create a Swing frame, then add a label to it, it’ll fill the frame completely, and you’ll be unable to move or re-size The default layout manager for a Swing frame is BorderLayout. Sizes and location of components are governed by a strict policy. To change, select the content pane in design view or Java Beans view, then change layout manager in Properties view Null layout, for example, lets you modify components’ sizes and placement arbitrarily

VE supported Swing/AWT layouts VE supports the following layouts: Null layout BorderLayout BoxLayout CardLayout FlowLayout GridBagLayout GridLayout SpringLayout is not supported

VE layout customizers Different sets of tools tailored for each type of layout –Layout tools –Components Most complete support for null layout –Display grid –Tools for aligning components, matching size, spacing evenly Layout conversion –Best support converting from null layout to GridBagLayout—which is very useful, since GridBagLayout is difficult to work with

Adding listeners To make a GUI work, you need to add listeners to wire components together Listeners can be added by right-clicking on a components in design view or Java Beans view and selecting Events-> Handlers specific to a components can be selected directly Other events can be selected by selecting Add Events… Dialog box will show applicable listeners and adapters

Listeners and adapters Swing often offers a choice between a listener— which is an interface—and an adapter which is a class –An interface requires that you implement all the methods it defines –Most Swing interfaces have a corresponding adapter—a class that implements the interfaces methods with stubs –You subclass the adapter and only need to implement the methods you care about –The only disadvantage of adapters is that your event handler can’t subclass anything else VE will create all the code needed in either case, including method stubs for the listener interface, so it using a listener is not much of an inconvenience

Demo Building a click-counter application: Layout with null layout tools Change control names with refactoring Convert to GridBagLayout Add listeners Add listener code Run as Java Bean Add main() and run as Java app