Object Oriented Programming Ders 11: Interfaces Mustafa Emre İlal

Slides:



Advertisements
Similar presentations
Introduction to Swing Components Chapter 14. Part of the Java Foundation Classes (JFC) Provides a rich set of GUI components Used to create a Java program.
Advertisements

User Interface Design CSCI 201L Jeffrey Miller, Ph.D. HTTP :// WWW - SCF. USC. EDU /~ CSCI 201 USC CSCI 201L.
Fall 2007CS 225 Graphical User Interfaces Event Handling Appendix C.
 What are the basic GUI components we’ve learned so far? › JFrame › JPanel › JButton › JLabel › JTextArea › JTextField › JCheckBox › JRadioButton › Paint.
Unit 091 Introduction to GUI Programming Introduction to User Interfaces Introduction to GUI Programming GUI Design Issues GUI Programming Issues Java.
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.
Graphical User Interfaces (GUIs) GUI: An application that uses graphical objects to interact with users GUI applications consist of: –Events: A user or.
©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 4 th Ed Chapter Chapter 14 GUI and Event-Driven Programming.
©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 4 th Ed Chapter Chapter 14 GUI and Event-Driven Programming.
Creating a GUI with Swing. Introduction Very useful link: Swing – is a part of JFC (Java Foundation.
1 GUI Elements in Java Nelson Padua-Perez Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
CPSC150 Week 12 Graphical User Interfaces Chapter 11.
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.
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.
Introduction to Java Swing “We are the sultans of swing” – Mark Knopfler.
CS3 - AWT/Swing1 The Abstract Windowing Toolkit Since Java was first released, its user interface facilities have been a significant weakness –The Abstract.
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 Programming in Java
1 Event Driven Programming wirh Graphical User Interfaces (GUIs) A Crash Course © Rick Mercer.
Java Swing, Events and MVC Optional Readings: Eckel’s Thinking in Java: Chap 14 (
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 GUI CSCE 190 – Java Instructor: Joel Gompert Mon, July 26, 2004.
Introduction to Swing Components Chapter 14.  Part of the Java Foundation Classes (JFC)  Provides a rich set of GUI components  Used to create a Java.
Chapter 9: Visual Programming Basics Object-Oriented Program Development Using Java: A Class-Centered Approach.
GUIs in Java Swing, Events CS2110, SW Development Methods Readings: MSD, Chapter 12 Lab Exercise.
1 CSE 331 Event-driven Programming and Graphical User Interfaces (GUIs) with Swing/AWT slides created by Marty Stepp based on materials by M. Ernst, S.
 2002 Prentice Hall, Inc. All rights reserved Introduction Graphical User Interface (GUI) –Gives program distinctive “look” and “feel” –Provides.
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.
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.
Graphics and Event-Driven Programming in Java John C. Ramirez Department of Computer Science University of Pittsburgh.
CS Lecture 00 Swing overview and introduction Lynda Thomas
Java Programming: Advanced Topics 1 Components and Facilities for Rich Graphical User Interfaces Chapter 7.
CSE1030-HR GUI The Big Picture Building the View Building the Controller Separating the Concerns Going Further.
CSCI Swing1 The Abstract Windowing Toolkit Since Java was first released, its user interface facilities have been a significant weakness –The Abstract.
CS Fall 2012, Lab 09 Haohan Zhu. Boston University Slideshow Title Goes Here CS Fall 2012, Lab /20/2015 GUI - Graphical User Interface.
Programming with Java’s Swing API February 4, 2003 CMPS Advanced Programming Graphical User Interfaces.
Lec.10 (Chapter 8 & 9) GUI Jiang (Jen) ZHENG June 27 th, 2005.
CS 4244: Internet Programming User Interface Programming in Java 1.0.
Swing. Introduction to Swing What is Swing? “ Swing is a diverse collection of lightweight components that can be used to build sophisticated user interfaces.”
5-Jan-16 R Ramesh Swing. 5-Jan-16 R Ramesh An Introduction to Java Foundation Classes (JFC) A suite of libraries to assist programmers create enterprise.
The Swing GUI Components Chapter 29 An enhanced alternative to AWT The PC does not need an appletviewer or browser Swing overcomes some AWT drawbacks.
Graphical User Interface Components: Part 1 Chapter 11.
Graphical User Interfaces are Trees CS1316: Representing Structure and Behavior.
Basics of GUI Programming Chapter 11 and Chapter 22.
1 Chapter 16: Creating Windows. 2 Basics of GUI Programming How to create a Window. TryWindow.java You always need a JFrame component before creating.
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.
Java GUI COMP 401 Fall 2014 Lecture 16 10/20/2014.
Sadegh Aliakbary Sharif University of Technology Fall 2011.
Java Swing, Events Readings: Just Java 2: Chap 19 & 21, or Eckel’s Thinking in Java: Chap 14 Slide credits to CMPUT 301, Department of Computing Science.
Chapter 10 - Writing Graphical User Interfaces1 Chapter 10 Writing Graphical User Interfaces.
1 Lecture 8: User Interface Components with Swing.
5-1 GUIs and Events Rick Mercer. 5-2 Event-Driven Programming with Graphical user Interfaces  Most applications have graphical user interfaces to respond.
CIS 270—Application Development II Chapter 11—GUI Components: Part I.
Introduction to Swing Mr. Crone. What is Swing? a collection of pre-made Java classes used to create a modern graphical user interface.
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:
Introduction to Swing Mr. Crone. What is Swing? a collection of pre-made Java classes used to create a modern graphical user interface.
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 1: JFC and Swing Basics OOP tirgul No
Java Swing What is swing? Swing is a ”Lightweight” GUI ToolKit for Java Different from AWT / SWT Toolkits for GUIs Few lines of code to produce GUI elements.
A Quick Java Swing Tutorial
A Quick Java Swing Tutorial
Ellen Walker Hiram College
Event Driven Programming and Graphical User Interface
GUIS: Graphical User Interfaces
תכנות מכוון עצמים בשפת JAVA
Week 8 Swing NetBeans GUI Builder
A Quick Java Swing Tutorial
Advanced Programming in Java
Presentation transcript:

Object Oriented Programming Ders 11: Interfaces Mustafa Emre İlal

Recap Assignment 9 The Collections Framework

Today Assignment 10 Interfaces – Swing classes Thinking in Java – Chapter 14

User Interface Graphical User Interface [GUI] "gooey" Every operating system’s (platform) windowing mechanisms differ vastly For each platform the GUI code needs to be redesigned Java interface runs on the Java platform and is developed only once

java.awt.* and javax.swing.* Java’s GUI classes are in these two packages AWT (Abstract Windowing Toolkit) – old; were not totally platform independent –Button –TextField Swing (part of JFC) – recommended; platform independent, provides more options –JButton –JTextField

Main windows 3 often used windows (top-level containers) JFrame JDialog JApplet

Containers JPanel JScrollPane JTabbedPane JToolBar JSplitPane

Controls (widgets) JMenu JSpinner JSlider JTextField JComboBox JButton JList JRadioButton JCheckBox

Information JProgressBar JLabel JToolTip

Complex Classes JFileChooser JTree JTable JColorChooser

Windows Components are placed in containers which are in turn placed inside other containers to form a tree- like hierarchy

Layout Manager When components are placed into a containers, where they appear is controlled by rules that are handled by LayoutManager s Each container will have a LayoutManager. Various LayoutManagers: –FlowLayout –GridLayout –BorderLayout –etc.

Example Layouts

Event User interacts with our application through the operating system interface Keyboard and mouse is tracked by the OS. Movement of the mouse, click on a button, pressing on a key are all “events” Applications are notified by the OS about events that occur over their windows. Making sense out of events (user requests) and responding to them are the applications’ responsibility.

Event The events that are sent by the OS to the Java apps are represented by either an “awt event” or a “swing event” and are associated with the component they occur on. AWTEvent ActionEventComponentEventWindowEvent MouseEventMouseMotionEventFocusEvent KeyEventContainerEventHierarchyEvent InputMethodEventItemEventvs Swing Event ListSelectionListenerMenuListenerHyperlinkListener TreeSelectionListenerDocumentEventvs

EventListener When an event takes place, starting with the component it takes place on, all the elements in the GUI hierarchy above the source component gets notified These components in turn notify all the EventListeners that have registered with them for the type of event that has occured EventListeners need to be written by you and have to implement the proper EventListener interface.

Example – EventListener public class MyClass implements ActionListener {... public void actionPerformed(ActionEvent e) {... } MyClass mc = new MyClass(); someComponent.addActionListener(mc);

Assignment 12a Write an application that reads a text file and displays the number of vowels and consonents on a GUI. TextFile.txt Consonents Vowels Read Reading complete

Assignment 12b Develop a GUI for the application you have written for assignment 11 : –Whenever the “Create Shapes” button is pressed, create 10 random shapes and display them on the canvas. (pay attention to shape sizes) Create Shapes

Next Week Final exam? Review Projects...