Chapter 6 Graphical User Interface (GUI) and Object-Oriented Design (OOD)

Slides:



Advertisements
Similar presentations
Unit 3 Graphical User Interface (GUI) Dr. Magdi AMER.
Advertisements

Graphic User Interfaces Layout Managers Event Handling.
1 Chapter 8 Objects and Classes Lecture 2 Prepared by Muhanad Alkhalisy.
Introduction to Java Classes, events, GUI’s. Understand: How to use TextPad How to define a class or object How to create a GUI interface How event-driven.
Corresponds with Chapter 12
IEEM 110 Computing in Industrial Applications Basic User Interface in Java.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved L04 (Chapter 15) Creating.
1 GUI Elements in Java Nelson Padua-Perez Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
Unit 11 Object-oriented programming: Graphical user interface Jin Sa.
Chapter 6 Graphical User Interface (GUI) and Object-Oriented Design (OOD)
1 Class 8. 2 Chapter Objectives Use Swing components to build the GUI for a Swing program Implement an ActionListener to handle events Add interface components.
Chapter 6: Graphical User Interface (GUI) and Object-Oriented Design (OOD) J ava P rogramming: Program Design Including Data Structures Program Design.
Graphic User Interfaces Part 1. Typical GUI Screen from Microsoft Word What GUI “components” can you see? –Menus? Buttons? Labels? What else? –Anything.
PROGRAMMING REVIEW Lab 2 EECS 448 Dr Fengjun Li and Meenakshi Mishra.
Java Programming Chapter 10 Graphical User Interfaces.
ACM/JETT Workshop - August 4-5, ExceptionHandling and User Interfaces (Event Delegation, Inner classes) using Swing.
JLabel, JTextField, JButton and JOptionPane
Chapter 8: Writing Graphical User Interfaces
Liang, Introduction to Java Programming, Fifth Edition, (c) 2005 Pearson Education, Inc. All rights reserved Chapter 13 Creating User.
Java Programming: From Problem Analysis to Program Design, Second Edition1  Learn about basic GUI components.  Explore how the GUI components JFrame,
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.
GUI programming Graphical user interface-based programming.
GUIs in Java Swing, Events CS2110, SW Development Methods Readings: MSD, Chapter 12 Lab Exercise.
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.
MSc Workshop - © S. Kamin, U. ReddyLect 3 - GUI -1 Lecture 3 - Graphical User Interfaces r GUI toolkits in Java API r JFrame r GUI components.
Timer class and inner classes. Processing timer events Timer is part of javax.swing helps manage activity over time Use it to set up a timer to generate.
ITEC 109 Lecture 27 GUI. GUIs Review Sounds –Arrays hold sample values –Creating a keyboard –Sound effects Homework 3 –The big two –Due after break –Lab.
Object-Oriented Program Development Using Java: A Class-Centered Approach, Enhanced Edition.
Creating Windows. How can we use Java to create programs that use windows (GUI applications)? How can we use Java to create programs that use windows.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved Chapter 15 Creating User.
Java GUI. Graphical User Interface (GUI) a list a button a text field a label combo box checkbox.
Introduction to GUI in 1 Graphical User Interface 2 Nouf Almunyif.
1 GUI programming Graphical user interface-based programming Chapter G1 (pages )
Java Programming: From Problem Analysis to Program Design, 3e Chapter 6 Graphical User Interface (GUI) and Object-Oriented Design (OOD)
GUIs Graphical User Interfaces. Everything coming together Known: – Inheritance – Interfaces – Abstract classes – Polymorphism – Exceptions New: – Events.
Object-Oriented Application Development Using VB.NET 1 Chapter 10 VB.NET GUI Components Overview.
GUI Basics. Agenda What GUI How to make in java Creating frames Frequently used GUI components Layout Managers.
Java Programming: From Problem Analysis to Program Design, Second Edition1 Lecture 5 Objectives  Learn about basic GUI components.  Explore how the GUI.
Chapter 11 - A GUI Interacting With a Problem Domain Class1 Chapter 11 A GUI Interacting With a Problem Domain Class 11.
Basics of GUI Programming Chapter 11 and Chapter 22.
Creating a Window. A basic window in Java is represented by an object of the class Window in the package java.awt.
Sadegh Aliakbary Sharif University of Technology Fall 2011.
JAVA: An Introduction to Problem Solving & Programming, 6 th Ed. By Walter Savitch ISBN © 2012 Pearson Education, Inc., Upper Saddle River,
Chapter 10 - Writing Graphical User Interfaces1 Chapter 10 Writing Graphical User Interfaces.
Graphical User Interface (GUI)
Chapter 6 Graphical User Interface (GUI) and Object-Oriented Design (OOD)
Introduction to GUI Programming in Java: Frames, Simple Components, and Layouts.
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.
GUIs & Event-Driven Programming Chapter 11 Review.
SE-1020 Dr. Mark L. Hornick 1 Creating Graphical User Interfaces.
©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Chapter Chapter 7 ( Book Chapter 14) GUI and Event-Driven Programming.
©TheMcGraw-Hill Companies, Inc. Permission required for reproduction or display. Chapter 7 Event-Driven Programming and Basic GUI Objects.
Java Programming: Guided Learning with Early Objects
Java GUI.
Graphical User Interface (pronounced "gooey")
Java Programming: From Problem Analysis to Program Design,
A Quick Java Swing Tutorial
Ellen Walker Hiram College
Chapter 14 JavaFX Basics Dr. Clincy - Lecture.
Timer class and inner classes
Graphical user interface-based programming
Graphical User Interfaces in Java Event-driven programming
A Quick Java Swing Tutorial
Advanced Programming in Java
CiS 260: App Dev I Chapter 6: GUI and OOD.
Graphical User Interface
Presentation transcript:

Chapter 6 Graphical User Interface (GUI) and Object-Oriented Design (OOD)

Chapter Objectives  Learn about classes used to build simple GUIs  Learn to use GUI components Frame, Label, Textile, and JButton  Become familiar with the concept of event-driven programming, events and event handlers  Explore object-oriented design using GUI as an one example  Learn how to identify objects, classes, and members of a class

Graphical User Interface (GUI) Components  We have already met JOptionPane from the swing library. It allowed us to use single variable text input boxes and information boxes  Now we will look at the basic components used to build User interfaces which allow us to:  view inputs and outputs simultaneously in a single window  To Input values of inputs in any order  To change input values in window  To click on buttons to initiate an action to produce an output

Java GUI Components

Graphical User Interface (GUI) Components  GUI components  Windows  Labels  Text areas  Buttons  A Window has a title, a content pane, additional GUI components can be placed on the content pane  Labels indicate what the contents of a text box is, what the purpose of a button is, etc.  A text area can be used to display and/or input data  Pushing a button is associated with an action or event

GUI Creation  First create a Window with a label indicating the purpose of the GUI. You can specify the size of the window in pixels.  Access the content pane of the window and choose the layout of the components  Add the desired GUI components (labels and text areas)  Add any buttons and handle the events associated with those buttons

Creating a Window  Create a Window by declaring an instance of a JFrame object, by using a constructor.  The class JFrame provides various methods to control attributes of a window  Attributes associated with window objects  Title  Width (measured in pixels)  Height (measured in pixels)

Methods Provided by the class Frame

Two Ways to Create a Window  First way  Declare object of type JFrame  Instantiate object  Use various methods to manipulate window  Second way  Create subclass of JFrame containing application program by extending definition of class JFrame. JFrame is a superclass of the new subclass  Utilizes mechanism of inheritance

Content Pane  Inner area of GUI window (below title bar, inside border)  To access content pane:  Declare reference variable of type Container  Use method getContentPane of class JFrame

Methods Provided by the class Container

class JLabel  Class to create and modify JLabel objects (labels)  A label may be aligned left, center or right  A label may include text and/or an icon  To create a label  Declare and Instantiate object of type JLabel  May modify attributes to control display of labels  To add a label to a container (display the label in the content pane) use the method add from the container class

Methods Provided by the class JLabel

class JTextField  Used to create and modify JTextField objects belonging to class JTextField  Text field may accept input or display values  May specify length in characters of text field  To create text field  Declare reference variable of type JTextField  Instantiate object  To add a text field to a container (display the label in the content pane) use the method add from the container class

Methods Provided by the class JTextField