PROGRAMMING GRAPHICAL USER INTERFACES Lecture 21 JAVA GUI BASICS Basic Java GUI Components –java.awt.Component, java.awt.Container, javax.swing.JComponent,

Slides:



Advertisements
Similar presentations
Event handling and listeners What is an event? user actions and context event sources and listeners Why should my programs be event- driven? User interaction.
Advertisements

1 Event Listeners Some Events and Their Associated Event Listeners Act that Results in the EventListener Type User clicks a button, presses Enter while.
Programming in Java; Instructor:John Punin Graphics and Graphical User Interfaces1 Programming in Java Graphics and Graphical User Interfaces.
Event Handling.
Fall 2007CS 225 Graphical User Interfaces Event Handling Appendix C.
CSE 331 SOFTWARE DESIGN & IMPLEMENTATION GUI & (A LITTLE ON) DESIGN PATTERNS III Autumn 2011.
Event Handling n Events: an event is an object that describes a state change in a source. n Event Sources: A source is an object that generates an event.
1 Gui Programming (Part I) Graphical User Interfaces (Part I) l Introduction to events. l A Brief history. l Event sources and listeners. l The delegation.
Intermediate Java1 An example that uses inner classes Week Four Continued.
EVENTS CSC 171 FALL 2004 LECTURE 16. “Traditional” Input In console applications, user input is under control of the program The program asks the user.
Events in Java Swing Chris North cs3724: HCI. Typical command line program Non-interactive Linear execution program: main() { code; }
Applets, AWTS CompSci 230 Software Construction.
MIT AITI 2003 Lecture 17. Swing - Part II. The Java Event Model Up until now, we have focused on GUI's to present information (with one exception) Up.
Java Programming: Advanced Topics 1 Common Elements of Graphical User Interfaces Chapter 6.
Cs884(Prasad)java12AWT1 Abstract Windowing Toolkit Support for Graphical User Interface (Event-driven programming)
CS 11 java track: lecture 4 This week: arrays interfaces listener classes inner classes GUI callbacks.
Java GUI’s are event driven, meaning they generate events when the user interacts with the program. Typical events are moving the mouse, clicking a mouse.
Dale Roberts GUI Programming using Java - Event Handling Dale Roberts, Lecturer Computer Science, IUPUI Department of Computer.
Graphical User Interface Components: Part 1 Chapter 11.
 2002 Prentice Hall, Inc. All rights reserved Introduction Graphical User Interface (GUI) –Gives program distinctive “look” and “feel” –Provides.
1 CIS 421 Web Based Java Programming Building GUIs (Graphical User Interfaces) with Java Part 1.
– 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.
1 Unit 5 GUI Aum Amriteshwaryai Namah. 2 Overview Shall learn how to reuse the graphics classes provided by Java for constructing Graphical User Interface.
COMP 321 Week 2. Outline Event-Driven Programming Events, Event Sources, Event Listeners Button and Timer Events Mouse Events, Adapters.
GUI Graphical User Interface. Outline Introduction Packages Components Layout Manager Events and Listeners Examples.
CompSci 230 S Software Construction Applets & AWT.
Omer Boyaci.  GUIs are event driven.  When the user interacts with a GUI component, the interaction—known as an event—drives the program to perform.
CS102 – GUI AWT & Swing Components & Containers, Layout Managers, Events & Listeners MVC design pattern. David Davenport.
Pravin Yannawar, DOCS, NMU Jalgaon. Basic Java : Event handling in AWT and Swing 2 Objectives of This Session Explain the Event handling mechanism & demonstrate.
1 / 67 COP 3503 FALL 2012 SHAYAN JAVED LECTURE 14 Programming Fundamentals using Java 1.
Event Handling. 2 GUIs are event driven –Generate events when user interacts with GUI e.g., moving mouse, pressing button, typing in text field, etc.
CS1054: Lecture 21 - Graphical User Interface. Graphical User Interfaces vs. Text User Interface.
Introduction to Java Programming
Java GUI. Graphical User Interface (GUI) a list a button a text field a label combo box checkbox.
Universidad Nacional de Colombia Facultad de Ingeniería Departamento de Sistemas ertificación en AVA.
Week 6: Basic GUI Programming Concepts in Java Example: JFrameDemo.java container : a screen window/applet window/panel that groups and arranges components.
Event Handling. The signals that a program receives from the operating system as a result of the actions are called events. A window based program is.
Agenda Introduction. Event Model. Creating GUI Application. Event Examples.
GUI DYNAMICS Lecture 11 CS2110 – Fall GUI Statics and GUI Dynamics  Statics: what’s drawn on the screen  Components buttons, labels, lists, sliders,
Events in JAVA Needed for Applets and GUI based programs. Applet uses GUI to interact with user. Most of the events are generated by Mouse, Keyboard.
Java GUI COMP 401 Fall 2014 Lecture 16 10/20/2014.
CS Lecture 04 Mice Lynda Thomas
1 Event Handling – Lecture 4 Prepared by: Ahmad Ramin Rahimee Assistant Professor ICTI.
What Is an Event? Events – Objects that describe what happened Event sources – The generator of an event Event handlers – A method that receives an event.
 Figure illustrates a hierarchy containing many event classes from the package java.awt.event.  Used with both AWT and Swing components.  Additional.
CSI 3125, Preliminaries, page 1 Event Handling. CSI 3125, Preliminaries, page 2 Event Handling An Event Change in the state of an object is known as event.
Mouse Events GUI. Types of Events  Below, are some of the many kinds of events, swing components generate. Act causing EventListener Type User clicks.
1 Lecture 8: User Interface Components with Swing.
UQC117S2 Graphics Programming Lecture 2 Event Handling Program as a sequence of instructions Event -driven program Need to detect the event and carry out.
Sep 181 Example Program DemoTranslateEnglishGUI.java.
Prepared by: Dr. Abdallah Mohamed, AOU-KW Unit7: Event-driven programming 1.
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.
GUI Programming using Java - Event Handling
Events and Event Handling
Welcome To java
Object-Orientated Analysis, Design and Programming
Programming in Java, 2e Sachin Malhotra Saurabh Choudhary.
CHAPTER Reacting to the user.
Chapter 12 Event-Driven Programming
Aum Amriteshwaryai Namah
Handling User Events with Swing
Mouse Event Handling in Java (Review)
Programming in Java Event Handling
GUI Programming III: Events
CSE Software Engineering Fall 1999 Updated by J. Brown
Event-driven programming for GUI
Week 8 Swing NetBeans GUI Builder
Printing in Java Printing in Java 1.1 is implemented through the new PrintJob class and PrintGraphics interface When a PrintJob object is created, the.
Presentation transcript:

PROGRAMMING GRAPHICAL USER INTERFACES Lecture 21 JAVA GUI BASICS Basic Java GUI Components –java.awt.Component, java.awt.Container, javax.swing.JComponent, …java.awt.Componentjava.awt.Containerjavax.swing.JComponent Event handling –packages java.awt.event and javax.swing.eventjava.awt.eventjavax.swing.event Creating UI layouts –using and creating layout managers –java.awt.LayoutManager and java.awt.LayoutManager2java.awt.LayoutManagerjava.awt.LayoutManager2 Using resources –using resource bundles for different locales –java.util.ResourceBundlejava.util.ResourceBundle

PROGRAMMING GRAPHICAL USER INTERFACES Lecture 22 COMPONENTS Component addMouseListener() addKeyListener()... getBounds() getComponentAt()... void paint(Graphics) Container add(Component) remove(Component) setLayoutManager()... Button Canvas Label... Panel Box Window... JComponent setBorder() setUI()... Swing Components AWT Swing

PROGRAMMING GRAPHICAL USER INTERFACES Lecture 23 WINDOWS & FRAMES Container add(Component) remove(Component) setLayoutManager()... Window addWindowListener() pack() show()... Frame setIconImage() setMenuBar() setTitle()... Dialog setModal() setTitle()... MenuContainer JFrame getContentPane() setJMenuBar()... contentPane JWindow JDialog getContentPane()... contentPane Swing AWT

PROGRAMMING GRAPHICAL USER INTERFACES Lecture 24 LAYOUT Container add(component) add(component, constraints) add(name, component) remove(Component) setLayoutManager() validate() doLayout()... layoutManager LayoutManager addLayoutComponent(name, component) removeLayoutComponent(component) preferredLayoutSizer() minimumLayoutSize() layoutContainer(container) LayoutManager2 addLayoutComponent(comp, constraints) invalidateLayout() maximumLayoutSize()... FlowLayoutGridLayout BoxLayoutCardLayoutOverlayLayoutGridBagLayoutBorderLayout... layoutManager.layoutContainer(this);...

PROGRAMMING GRAPHICAL USER INTERFACES Lecture 25 EVENTS EventListener Component addMouseListener(listener) removeMouseListener(listener) processMouseEvent(mouseEvent)... listenerList MouseListener mouseClicked(mouseEvent) mousePressed(mouseEvent) mouseReleased(mouseEvent) mouseEntered(mouseEvent) mouseExited(mouseEvent) ActionListener MouseMotionListener KeyListener mouseEvent( MOUSE_PRESSED, 123, 456) MouseEvent getX() getY() getClickCount()

PROGRAMMING GRAPHICAL USER INTERFACES Lecture 26 EVENTS cont’d MouseEvent getX() getY() getClickCount() KeyEvent ActionEvent InputEvent getModifiers() getWhen() ComponentEvent getComponent() FocusEventWindowEvent AWTEvent getID() EventObject getSource() many notification event types other AWT events ContainerEventPaintEvent