Nov 181 Example Program DemoTree2.java DemoTree.java.

Slides:



Advertisements
Similar presentations
Chapter 18 Building the user interface. This chapter discusses n Javas graphical user interface. n Swing: an enhancement of a library called the Abstract.
Advertisements

CE881: Mobile and Social Application Programming Simon M. Lucas Menus and Dialogs.
Graphics Programming. Introduction GOAL: Build the Indexer Client Event-driven vs. Sequential programs Terminology – Top-level windows are called “frame.
Containers and Components 1.Containers collect GUI components 2.Sometimes, want to add a container to another container 3.Container should be a component.
Copyright © 2012 Pearson Education, Inc. Chapter 9 Delegates and Events.
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.
1 Patterns & GUI Programming Part 2. 2 Creating a Custom Layout Manager Layout manager determines how components are arranged/displayed in a container.
Frameworks: Swing Case Study David Talby. Frameworks A reusable, semi-complete application An object-oriented technique Reuse of both code & design Hollywood.
THE SWING UI TOOLKIT Mostly from “The Swing Connection”The Swing Connection.
The Composite Pattern.. Composite Pattern Intent –Compose objects into tree structures to represent part-whole hierarchies. –Composite lets clients treat.
Command Design Pattern Source: Design Patterns – Elements of Reusable Object- Oriented Software; Gamma, et. al.
Object-Oriented Analysis and Design
Design patterns Observer,Strategi, Composite,Template (Chap 5, 6)
GUI Programming in Java Tim McKenna GUI Programming Concepts l conventional programming: sequence of operations is determined by the program.
Introduction to Java Swing “We are the sultans of swing” – Mark Knopfler.
A.k.a. GUI’s.  If you want to discuss your Lab 2 grade come see me this week. ◦ Office: 436 ERB. One hour prior to class ◦ Open to Appointments MWF 
GUI Basics: Introduction. Creating GUI Objects // Create a button with text OK JButton jbtOK = new JButton("OK"); // Create a label with text "Enter your.
GUI Programming in Java
W14 - Building World-Class UIs with JFC - Ted Faison1 Building World-Class User Interfaces with Java Foundation Classes Ted Faison Faison Computing Inc.
ACM/JETT Workshop - August 4-5, ExceptionHandling and User Interfaces (Event Delegation, Inner classes) using Swing.
1 Chapter Eleven Handling Events. 2 Objectives Learn about delegates How to create composed delegates How to handle events How to use the built-in EventHandler.
Field Trip #19 Animations with Java By Keith Lynn.
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.
SWING IF YOU GET LOST - IMPORTANT LINKS  Swing articles:
Java Graphics Stuart Hansen 11/6/03. What’s Wrong with OpenGL Graphics – not GUI –No real support of text boxes, buttons, etc. Procedural - not OOP –No.
3461 Model-View Controller Advanced GUI concepts.
CS Lecture 00 Swing overview and introduction Lynda Thomas
Creating Your Own Widgets CompSci 230 S Software Construction.
Java GUI. Graphical User Interface (GUI) a list a button a text field a label combo box checkbox.
Graphics in Java Dr. Andrew Wallace PhD BEng(hons) EurIng
GUIs Graphical User Interfaces. Everything coming together Known: – Inheritance – Interfaces – Abstract classes – Polymorphism – Exceptions New: – Events.
Class Builder Tutorial Presented By- Amit Singh & Sylendra Prasad.
Fall UI Design and Implementation1 Lecture 15: Undo.
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.
Liang, Introduction to Java Programming, Tenth Edition, (c) 2015 Pearson Education, Inc. All rights reserved. 1 Chapter 15 Event-Driven Programming and.
Traits User Interface Class David C. Morrill Enthought, Inc.
Chapter 10 - Writing Graphical User Interfaces1 Chapter 10 Writing Graphical User Interfaces.
UQC117S2 Graphics Programming Lecture 2 Event Handling Program as a sequence of instructions Event -driven program Need to detect the event and carry out.
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:
©TheMcGraw-Hill Companies, Inc. Permission required for reproduction or display. Chapter 7 Event-Driven Programming and Basic GUI Objects.
Chapter 32 JavaBeans and Bean Events
A Quick Java Swing Tutorial
Creating Your Own Widgets
Modern Programming Tools And Techniques-I
Chapter 15 Event-Driven Programming and Animations
Aum Amriteshwaryai Namah
Behavioral Design Patterns
Review: Java GUI Programming
Lecture 27 Creating Custom GUIs
Object-Oriented Programming & Design Lecture 18 Martin van Bommel
University of Central Florida COP 3330 Object Oriented Programming
Chapter Eleven Handling Events.
Lecture 28 Concurrent, Responsive GUIs
Note 11 Command Pattern SE2811 Software Component Design
A Quick Java Swing Tutorial
COSC-4840 Software Engineering
Ellen Walker Hiram College
Event Driven Programming
Doug Jeffries CS490 Design Patterns May 1, 2003
Event Driven Programming and Graphical User Interface
12. Command Pattern SE2811 Software Component Design
Lecture 22 Inheritance Richard Gesick.
Composite Pattern Context:
Event Driven Systems and Modeling
Week 8 Swing NetBeans GUI Builder
A Quick Java Swing Tutorial
Constructors, GUI’s(Using Swing) and ActionListner
Fundaments of Game Design
12. Command Pattern SE2811 Software Component Design
Presentation transcript:

Nov 181 Example Program DemoTree2.java DemoTree.java

Nov 182 ComponentUI Class The delegate part of a component is derived from an abstract class named ComponentUI Naming convention: remove the “J” from the component’s class name, then add “UI” to the end (e.g., JButton  ButtonUI) ComponentUIButtonUIBasicButtonUI MenuButtonUI MultiButtonUI CustomButtonUI

Nov 183 Design Challenge A corporation specializing in children’s games wishes to use a custom “corporate style” in all their applications As one example, they’d like the buttons for their applications to look as follows… Design a custom L&F for a JButton, as above Normal Armed FUNNY STUFF KIDS STUFF FUNNY STUFF KIDS STUFF Pressed FUNNY STUFF KIDS STUFF

Nov 184 Example Program DemoCustomButtonUI.java

Nov 185 Preferred Size Property An important task for a window manager is determining the size of widgets What happens when getPreferredSize is invoked on a JButton? JButton’s getPreferredSize method is inherited from JComponent Let’s see…

Nov 186 /** * If the preferredSize has been set to a non-null value * just returns it. If the UI delegate's getPreferredSize() * method returns a non null value then return that; otherwise * defer to the component's layout manager. * the value of the preferredSize property #setPreferredSize */ public Dimension getPreferredSize() { if (preferredSize != null) { return preferredSize; } Dimension size = null; if (ui != null) { size = ui.getPreferredSize(this); } return (size != null) ? size : super.getPreferredSize(); } getPreferredSize (from JComponent.java) Returns either… Value set with setPreferredSize, Value from UI delegate, or Value from Container

Nov 187 Programming Challenge Solution Create a new version of DemoSizeProperties that presents the component name, class, and size properties in a JTable Name the new program… PC_SizeProperties.java

Nov 188 Undo/Redo in Swing Swing provides facilities for generalized, unlimited Undo/Redo Relevant classes: UndoManager AbstractUndoableEdit(default implementation of the UndoableEdit interface)

Nov 189 Undo/Redo Setup (step 1) For each operation that you would like your user to be able to undo, create a subclass of AbstractUndoableEdit You may need to provide implementation for the following methods: undo() redo() canUndo() canRedo() getPresentationName()

Nov 1810 Undo/Redo Setup (step 2) Create an instance of the UndoManager class You can call the following methods on this instance: undo() redo() addEdit(UndoableEdit) canUndo() canRedo() getUndoPresentationName() getRedoPresentationName()

Nov 1811 Example program DemoUndo.java