CIS 270—Application Development II Chapter 11—GUI Components: Part I.

Slides:



Advertisements
Similar presentations
Introduction to Java 2 Programming
Advertisements

Unit 3 Graphical User Interface (GUI) Dr. Magdi AMER.
Graphic User Interfaces Layout Managers Event Handling.
Corresponds with Chapter 12
Fall 2007CS 225 Graphical User Interfaces Event Handling Appendix C.
Chapter 6 Graphical User Interface (GUI) and Object-Oriented Design (OOD)
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.
Lecture 15 Graphical User Interfaces (GUI’s). Objectives Provide a general set of concepts for GUI’s Layout manager GUI components GUI Design Guidelines.
Graphical User Interfaces (GUIs) GUI: An application that uses graphical objects to interact with users GUI applications consist of: –Events: A user or.
Chapter 121 Window Interfaces Using Swing Chapter 12.
Graphical User Interface Components: Part 1
GUI Programming in Java Tim McKenna GUI Programming Concepts l conventional programming: sequence of operations is determined by the program.
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.
GUI Programming in Java
Java Programming Chapter 10 Graphical User Interfaces.
Welcome to CIS 083 ! Events CIS 068.
Liang, Introduction to Java Programming, Fifth Edition, (c) 2005 Pearson Education, Inc. All rights reserved Chapter 13 Creating User.
CIS 068 Welcome to CIS 083 ! Introduction to GUIs: JAVA Swing.
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 Programming: Advanced Topics 1 Common Elements of Graphical User Interfaces Chapter 6.
Java How to Program, 9/e © Copyright by Pearson Education, Inc. All Rights Reserved.
Dale Roberts GUI Programming using Java - Event Handling Dale Roberts, Lecturer Computer Science, IUPUI Department of Computer.
Dale Roberts GUI Programming using Java - Introduction Dale Roberts, Lecturer Computer Science, IUPUI Department of Computer.
Graphical User Interface Components: Part 1 Chapter 11.
Ch 3-4: GUI Basics Java Software Solutions Foundations of Program Design Sixth Edition by Lewis & Loftus Coming up: GUI Components.
 2002 Prentice Hall, Inc. All rights reserved Introduction Graphical User Interface (GUI) –Gives program distinctive “look” and “feel” –Provides.
– Advanced Programming P ROGRAMMING IN Lecture 21 Introduction to Swing.
1 Outline 1 Introduction 2 Overview of Swing Components 3 JLabel 4 Event Handling 5 TextFields 6 How Event Handling Works 7 JButton 8 JCheckBox and JRadioButton.
Graphic User Interface. Graphic User Interface (GUI) Most of us interact with computers using GUIs. GUIs are visual representations of the actions you.
GUI Clients 1 Enterprise Applications CE00465-M Clients with Graphical User Interfaces.
Graphics and Event-Driven Programming in Java John C. Ramirez Department of Computer Science University of Pittsburgh.
CS Fall 2012, Lab 09 Haohan Zhu. Boston University Slideshow Title Goes Here CS Fall 2012, Lab /20/2015 GUI - Graphical User Interface.
GUI Basics. What is GUI? A graphical user interface (GUI) is a type of user interface item that allows people to interact with programs in more ways than.
Swing / Session1 / 1 of 30 Module Introduction Distributed Computing in Java.
Java GUI. Graphical User Interface (GUI) a list a button a text field a label combo box checkbox.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 6 – Graphical User Interfaces Java Foundations: Introduction to Programming.
Swing Components. Introduction Swing – A set of GUI classes – Part of the Java's standard library –Much better than the previous library: AWT Abstract.
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.
GUI Basics. Agenda What GUI How to make in java Creating frames Frequently used GUI components Layout Managers.
Swing. Introduction to Swing What is Swing? “ Swing is a diverse collection of lightweight components that can be used to build sophisticated user interfaces.”
Graphical User Interface Components: Part 1 Chapter 11.
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.
Graphical User Interfaces Tonga Institute of Higher Education.
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.
Computer Science [3] Java Programming II - Laboratory Course Lab 4 -1 : Introduction to Graphical user interface GUI Components Faculty of Engineering.
JAVA: An Introduction to Problem Solving & Programming, 6 th Ed. By Walter Savitch ISBN © 2012 Pearson Education, Inc., Upper Saddle River,
 Figure illustrates a hierarchy containing many event classes from the package java.awt.event.  Used with both AWT and Swing components.  Additional.
Chapter 10 - Writing Graphical User Interfaces1 Chapter 10 Writing Graphical User Interfaces.
1 Lecture 8: User Interface Components with Swing.
Jozef Goetz Credits: Copyright  Pearson Education, Inc. All rights reserved. expanded by J. Goetz, 2016.
Introduction to GUI Programming in Java: Frames, Simple Components, and Layouts.
Java Programming Fifth Edition Chapter 13 Introduction to Swing Components.
©TheMcGraw-Hill Companies, Inc. Permission required for reproduction or display. Chapter 7 Event-Driven Programming and Basic GUI Objects.
GUI Programming using Java - Event Handling
JButton Chapter 11 Lecture 3.
Christopher Budo, Davis Nygren, spencer franks, Luke miller
Appendix I GUI Components and Event Handling
A First Look at GUI Applications
Graphical User Interface (pronounced "gooey")
Graphical User Interface (GUI) Components: Part 1 Java How to Program, 9 th Edition Chapter 14.
Ellen Walker Hiram College
Chapter 13: Advanced GUIs and Graphics
MSIS670: Object-Oriented Software Engineering
IFS410: Advanced Analysis and Design
Advanced Programming in Java
TA: Nouf Al-Harbi NoufNaief.net :::
TA: Nouf Al-Harbi NoufNaief.net :::
Presentation transcript:

CIS 270—Application Development II Chapter 11—GUI Components: Part I

Introduction GUI (graphical user ___________) GUI ____________: An object with which the user interacts. label text field button text area combo box menu

JOptionPane A dialog box (or just dialog) is an application window. The JOptionPane class in the javax._______ package provides simple dialogs for input / output (Fig. 11.2). String numberStr = JOptionPane.showInputDialog (“Enter first integer”); JOptionPane.showMessageDialog (null, “The sum is” + sum, “Sum of Two Integers”, JOptionPane.PLAIN_MESSAGE); The input dialog can input only ________. A string of numeric characters must be converted to a number. int number = Integer.parseInt(numberStr);

Overview of Swing Components Most applications need more than simple I/O dialogs. Before Java 1.2, AWT (_________ Windows Toolkit) was used to create GUIs, but these were platform dependent (heavyweight components). Most Swing components are platform independent (__________) components (pure Java, part of JFC). The inheritance hierarchy for Java GUIs is Object  Component  Container  JComponent JComponent is the superclass of all Swing lightweight components.

Text/Images in a Window JFrame object: A window with a _______ bar and min/max/close buttons. JLabel object: Provides a single line of read-only text, an image, or both text and image. Steps in creating a GUI (see Figs and 11.7): import required classes create a container class (subclass of _________) declare components in the container class create a constructor for the container set the layout instantiate the components set component properties add components to container create an application class that instantiates the container

Introduction to Event Handling GUIs are _______ driven. An event is a user interaction with a GUI component. An event handler is code that performs a task in response to an event. A JTextField object can receive text input. A JPasswordField object does likewise, but hides the input with an ______ character. A component receives _______ when a user clicks on it. Additional steps for event handling (see Figs and 11.10): in the container constructor instantiate an event-handler object register the component with the event-handler using addActionListener create a nested event-handler class that provides functionality

Events, Interfaces, and Event Handling Three objects in the event-handling mechanism: event source object (creates the event object) event ________ (contains info about the event) event listener object (receives the event object) Registering an event source object with an event listener object: textField1.addActionListener( handler ); When an ActionEvent object is created, the JVM dispatches that object to every actionPerformed method (in the interface _________________) with which the event object is registered.

JButton Types of buttons command, check box, toggle, radio The class AbstractButton declares common features of Swing buttons. Command buttons create _______________ objects when clicked. A JButton object (command button) can call the setRolloverIcon method. (Fig )

Buttons That Maintain State Three kinds of button have state (on/off or true/false status) JToggleButton, JCheckBox, JRadioButton When a JCheckBox object is clicked, an _____________ object is created and is handled by an ItemListener object, which calls the itemStateChanged method. JRadioButton objects represent mutually exclusive options (only one in a group can be selected). JRadioButton objects must be added to a ______________ object.

Review the programs in these sections.

Layout Managers Three ways to arrange components in a GUI: _________ positioning—specify size and position of each layout managers—easier than absolute, but control is lost visual programming w/ an _____—drag, drop, resize, etc. Layout managers arrange GUI components in a container for presentation purposes. Types of layout managers FlowLayout— simplest, components flow left to right ___________—arranges components into five regions GridLayout— components are placed in an r x c grid Complex layouts are possible by using a JPanel as a component that holds other components