Component-Based Software Engineering GUI Basics Paul J Krause.

Slides:



Advertisements
Similar presentations
User Interfaces II GUI – Awt, Swing, Web
Advertisements

Drawing in a frame – Java GUI
Problem Solving 6 GUIs and Event Handling ICS-201 Introduction to Computing II Semester 071.
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.
Fall 2007CS 225 Graphical User Interfaces Event Handling Appendix C.
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 GUI Libraries Swing Programming. Swing Components Swing is a collection of libraries that contains primitive widgets or controls used for designing.
© L.Lúcio, An example GUI in Java n Two graphic libraries in Java u AWT u Swing n Swing is more recent than AWT: u Built on top of AWT classes;
Creating a GUI with Swing. Introduction Very useful link: Swing – is a part of JFC (Java Foundation.
Lecture 19 Graphics User Interfaces (GUIs)
1 lecture 12Lecture 13 Event Handling (cont.) Overview  Handling Window Events.  Event Adapters Revisited.  Introduction to Components and Containers.
Java GUI building with the AWT. 2 AWT (Abstract Window Toolkit) Present in all Java implementations Described in most Java textbooks Adequate for many.
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.
Lesson 35: Review of the Java GUI. The JFrame, Container and JButton.
Chapter 8: Graphical User Interfaces Objectives - by the end of this chapter, you should be able to do the following: –write a simple graphical user interface.
1 Java GUI programming. 2 On event-driven programming a user interface combines three functions: input, output, and data handling in batch-oriented processing.
Java Programming Chapter 10 Graphical User Interfaces.
Applets and Frames CS 21a: Introduction to Computing I First Semester,
OOP (Java): GUI I/ OOP Objectives – –describe some of the GUI controls and their listeners; more appear in part 13 Semester 2,
Java GUI building with the AWT. AWT (Abstract Window Toolkit) Present in all Java implementations Described in (almost) every Java textbook Adequate for.
Graphical User Interface CSI 1101 N. El Kadri. Plan - agenda Graphical components Model-View-Controller Observer/Observable.
Java GUI building with Swing. 2 AWT (Abstract Window Toolkit) Present in all Java implementations Described in (almost) every Java textbook Adequate for.
GUI Chapter 10 Graphics context and objects Creating a window based application JFrame, JTextField, JButton Containers and Controls Graphics commands Layout.
Objectives of This Session
Chapter 9: Visual Programming Basics Object-Oriented Program Development Using Java: A Class-Centered Approach.
CSTP FS99CS423 (cotter)1 Java Graphics java.awt.*;
GUIs in Java Swing, Events CS2110, SW Development Methods Readings: MSD, Chapter 12 Lab Exercise.
1 Block1 – unit 2 (The Case study in Budd 5-6).  create a small application that uses the Abstract Windowing Toolkit (AWT)  Swing packages to simulate.
1 CSC111H Graphical User Interfaces (GUIs) Introduction GUIs in Java Understanding Events A Simple Application The Containment Hierarchy Layout Managers.
– Advanced Programming P ROGRAMMING IN Lecture 21 Introduction to Swing.
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.
Chapter 12 1 TOPIC 13B l Buttons and Action Listeners Window Interfaces Using Swing Objects.
Layout Managers Arranges and lays out the GUI components on a container.
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.
CS102 – GUI AWT & Swing Components & Containers, Layout Managers, Events & Listeners MVC design pattern. David Davenport.
Introduction to GUI Programming with Java Graphical User Interfaces With AWT and Swing Towson University *Ref:
 GUI – Graphic User Interface  Up to now in the programs we have written all output has been sent to the standard output device i.e.: the DOS console.
Java GUI. Graphical User Interface (GUI) a list a button a text field a label combo box checkbox.
Week 6: Basic GUI Programming Concepts in Java Example: JFrameDemo.java container : a screen window/applet window/panel that groups and arranges components.
CS 4244: Internet Programming User Interface Programming in Java 1.0.
Ch13 Creating windows and applets. Short overview AWT (Abstract Windowing Toolkit) Early Java development used graphic classesEarly Java development used.
CIS Intro to JAVA Lecture Notes Set 8 9-June-05.
Java Swing One of the most important features of Java is its ability to draw graphics.
1 Layout Managers Layout managers –Provided for arranging GUI components –Provide basic layout capabilities –Processes layout details –Programmer can concentrate.
Event-Driven Programming F Procedural programming is executed in procedural order. F In event-driven programming, code is executed upon activation of events.
Chapter 10 - Writing Graphical User Interfaces1 Chapter 10 Writing Graphical User Interfaces.
Lesson 28: More on the GUI button, frame and actions.
1 Lecture 8: User Interface Components with Swing.
Lesson 33: Layout management and drawing – Java GUI.
MIT AITI 2004 Swing Event Model Lecture 17. The Java Event Model In the last lecture, we learned how to construct a GUI to present information to the.
Java Swing and Events Chris North cs3724: HCI. Presentations nadine edwards, steve terhar Vote: UI Hall of Fame/Shame?
Event Driven (Asynchronous) Programming. Event handling in Unity Subclass a class that contains event handling methods, and then override those methods.
Chapter 6 Building Java GUIs. MVC Model View Controller The model passes its data to the view for rendering The view determines which events are passed.
Lecture 6 Object Oriented Programming Using Java By Rashid Ahmad Department of Computer Science University of Peshawar.
Lecture 15 Basic GUI programming
Multiple buttons and action calls
Modular Event Handling
Introduction Many Java application use a graphical user interface or GUI (pronounced “gooey”). A GUI is a graphical window or windows that provide interaction.
Graphical User Interfaces
GUI building with the AWT
A First Look at GUI Applications
Ellen Walker Hiram College
Course Outcomes of Advanced Java Programming AJP (17625, C603)
GUI building with the AWT
Week 8 Swing NetBeans GUI Builder
Component-Based Software Engineering
CiS 260: App Dev I Chapter 6: GUI and OOD.
GUI building with the AWT
Graphical User Interface
Presentation transcript:

Component-Based Software Engineering GUI Basics Paul J Krause

Swing Overview  Components in the Abstract Windowing Toolkit (AWT) rely on the local platform’s GUI capabilities  Most Swing components are light-weight components - not “weighed-down” by the local platform’s GUI capabilities

Swing Overview java.lang.Object java.awt.Component java.awt.Container javax.swing.JComponent add( ) setlayout( ) setBorder( ) setOpaque( ) setToolTipText( ) paint( ) repaint( )

GUI Building in Swing  Need at least one top-level container  This is the root of a “containment hierarchy” this consists of all the Swing components that appear within that container this consists of all the Swing components that appear within that container  Often, the root will be a Jframe

JFrame

Pattern for Using JFrame import java.awt.*; import java.awt.event.*; import javax.swing.*; public class MyFrame extends JFrame { public MyFrame( ) { Container c = getContentPane(); c.setFlowLayout( new FlowLayout() ); c.add( Name of component here ); }

main method public static void main( String args[ ] ) { MyFrame test = new MyFrame( ); test.setSize( length, width ); test.show( ); }

Inner Class for event handling private class ActionEventHandler implements ActionListener { public void actionPerformed( ActionEvent e ) { if ( e.getSource( ) == exitButton ) System.exit(0); else if ( e.getSource( ) == something else ) { do something else } }}

Listening for actions public class MyFrame extends JFrame { public MyFrame( ) { public MyFrame( ) { Container c = getContentPane(); Container c = getContentPane(); c.setFlowLayout( new FlowLayout() ); c.setFlowLayout( new FlowLayout() ); ActionEventHandler handler = new ActionEventHandler( ); ActionEventHandler handler = new ActionEventHandler( ); JButton exitButton = new JButton( “Exit” ); JButton exitButton = new JButton( “Exit” ); exitButton.addActionListener( handler ); exitButton.addActionListener( handler ); c.add( exitButton ); c.add( exitButton );}

TimeTestWindow demo

Using NetBeans  Building a GUI is much easier and quicker using a visual development environment  Will illustrate this using NetBeans  Example taken from Chapter 8 of NetBeans - The Definitive Guide by Tim Boudreau, Jesse Glick, Simeon Greene, Vaughn Spurlin & Jack Woehr, O’Reilly