CS 112 GUI 06 May 2008 Bilkent. Java GUI API Containers: ◦ contain other GUI components. E.g, Window, Panel, Applet, Frame Dialog. Components: ◦ Buttons,

Slides:



Advertisements
Similar presentations
2D Graphics Drawing Things. Graphics In your GUI, you might want to draw graphics E.g. draw lines, circles, shapes, draw strings etc The Graphics class.
Advertisements

Graphic User Interfaces Layout Managers Event Handling.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 2-1 Outline Graphics Applets Drawing Shapes Components and Containers Images.
BuddySoft Painter Capstone Project Buddy Landry December 15, 2006.
Corresponds with Chapter 12
A graphical user interface (GUI) is a pictorial interface to a program. A good GUI can make programs easier to use by providing them with a consistent.
Chapter 6 Graphical User Interface (GUI) and Object-Oriented Design (OOD)
Liang, Introduction to Java Programming, Seventh Edition, (c) 2009 Pearson Education, Inc. All rights reserved Chapter 14 Graphics.
©2004 Brooks/Cole Applets Graphics & GUIs. Figures ©2004 Brooks/Cole CS 119: Intro to JavaFall 2005 Graphical Programs Most applications these days are.
Liang, Introduction to Java Programming, Fifth Edition, (c) 2005 Pearson Education, Inc. All rights reserved Chapter 13 Graphics.
Graphics Programming. In this class, we will cover: The difference between AWT and Swing Creating a frame Frame positioning Displaying information in.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved L01 (Chapter 13) Graphics.
Java Review Structure of a graphics program. Computer Graphics and User Interfaces Java is Object-Oriented A program uses objects to model the solution.
CPSC150 Week 12 Graphical User Interfaces Chapter 11.
10.1 AWT The AWT classes Users today expect a Graphical User Interface (GUI) Improves application usability Difficult to implement cross-platform.
Web Design & Development Lecture 18. Java Graphics.
Introduction to Java GUI Creating Graphical User Interfaces © copyright Bobby Hoggard / material may not be redistributed without permission.
Applets, AWTS CompSci 230 Software Construction.
20-753: Fundamentals of Web Programming Copyright © 1999, Carnegie Mellon. All Rights Reserved. 1 Lecture 16: Java Applets & AWT Fundamentals of Web Programming.
Java Software Solutions Lewis and Loftus Chapter 10 1 Copyright 1997 by John Lewis and William Loftus. All rights reserved. Graphical User Interfaces --
Java Programming: From Problem Analysis to Program Design, 4e Chapter 12 Advanced GUIs and Graphics.
1 CSC111H Graphical User Interfaces (GUIs) Introduction GUIs in Java Understanding Events A Simple Application The Containment Hierarchy Layout Managers.
JAPPLET.
(c) University of Washington07-1 CSC 143 Introduction to Graphical Interfaces in Java: AWT and Swing Reading: Ch. 17.
Adding Graphics to a Frame Application Applets: Can generate drawings by overriding paint Frame: Do not draw directly on a frame. Draw graphics on a JPanel.
Java Programming: Advanced Topics 1 Common Elements of Graphical User Interfaces Chapter 6.
Chapter 8: Getting Started with Graphics Programming Graphics Class Hierarchy Graphics Class Hierarchy Frames Frames The relationship between frame and.
CS 112 Department of Computer Science George Mason University CS 112 Department of Computer Science George Mason University Writing Graphic Applications.
Liang, Introduction to Java Programming, Seventh Edition, (c) 2009 Pearson Education, Inc. All rights reserved COS240 Object-Oriented Languages.
10/24/20151 Java GUI Programming. 10/24/20152 What is a GUI? Java has standard packages for creating custom Graphical User Interfaces Some of the fundamental.
School of Computer Science & Information Technology G6DICP - Lecture 17 GUI (Graphical User Interface) Programming.
Ch 3-4: GUI Basics Java Software Solutions Foundations of Program Design Sixth Edition by Lewis & Loftus Coming up: GUI Components.
Field Trip #19 Animations with Java By Keith Lynn.
1 CSC111H Graphical User Interfaces (GUIs) Introduction GUIs in Java Understanding Events A Simple Application The Containment Hierarchy Layout Managers.
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.
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.
MT311 Java Application Development and Programming Languages Li Tak Sing ( 李德成 )
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.
CS324e - Elements of Graphics and Visualization Java GUIs - Event Handling.
Lec.10 (Chapter 8 & 9) GUI Jiang (Jen) ZHENG June 27 th, 2005.
Agenda Java Coordinate Systems. Graphics Class. Drawing on Panels. Drawing Shapes.
The Abstract Window Toolkit (AWT) supports Graphical User Interface (GUI) programming. AWT features include: a rich set of user interface components; a.
Copyright © 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Programming Logic & Design Second Edition by Tony Gaddis.
SEEM3460 Tutorial GUI in Java. Some Basic GUI Terms Component (Control in some languages) the basic GUI unit something visible something that user can.
Intro to Applets. Applet Applets run within the Web browser environment Applets bring dynamic interaction and live animation to an otherwise static HTML.
Graphics basic 1. 2 Objectives Understand Java coordinate systems. Draw things using the methods in the Graphics class. Override the paintComponent method.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 6 – Graphical User Interfaces Java Foundations: Introduction to Programming.
Liang, Introduction to Java Programming, Seventh Edition, (c) 2009 Pearson Education, Inc. All rights reserved COS240 O-O Languages AUBG,
GUI DYNAMICS Lecture 11 CS2110 – Fall GUI Statics and GUI Dynamics  Statics: what’s drawn on the screen  Components buttons, labels, lists, sliders,
CIS Intro to JAVA Lecture Notes Set 8 9-June-05.
Review_6 AWT, Swing, ActionListener, and Graphics.
Basics of GUI Programming Chapter 11 and Chapter 22.
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 Swing One of the most important features of Java is its ability to draw graphics.
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.
Introduction to GUI Programming in Java: Frames, Simple Components, and Layouts.
Getting Started with GUI Programming Chapter 10 CSCI 1302.
A First Look at GUI Applications
Chapter Topics 15.1 Graphical User Interfaces
Ellen Walker Hiram College
Chap 7. Building Java Graphical User Interfaces
Graphical User Interfaces -- Introduction
Timer class and inner classes
Chapter 15: GUI Applications & Event-Driven Programming
Introduction to Graphical Interfaces in Java: AWT and Swing
Presentation transcript:

CS 112 GUI 06 May 2008 Bilkent

Java GUI API Containers: ◦ contain other GUI components. E.g, Window, Panel, Applet, Frame Dialog. Components: ◦ Buttons, ComboBox, List, Slider, Label etc. Helpers: ◦ Font, Color, Dimension, LayoutManager etc. Frame with normal window controls Optional Menu Three containers in Frame with Border Layout UI-components inside containers each with own layout

Layout Manager Flow Layout ◦ By default Border Layout Grid Layout Box Layout Why layout? Layouts provide flexibility in different environments with different screen resolutions

For X axis:

Graphics Previously, we have seen GUI components, their relationships, containers, layout managers. Now we will see how to paint graphics on GUI components

In this example if you resize the frame, line disappears, so how can we avoid this problem and display line permanently? -by inheriting Jlabel to draw line!

--The paintComponent method is invoked, whenever a component is first displayed or redisplayed! --To draw things on component you first declare a class that extends a swing GUI and override paintComponent method

The tester of SmileyFace:

Drawing Strings, Lines, Rectangles, and Ovals …

Drawing arcs

Draw Polygons

Event Driven Programming - In ED programming, code is executed when an event occurs - The program interacts with user and the events drive its execution. - Event is defined as a signal to the program that something has happened. - The component which an event is generated is called source object or source component. E.g., button

Simple example

Simple example with inner class Inner class is declared when it is only used by outer class And inner class can use the reference data and methods in outer class

Another inner class example Inner class also can be shortened by using anonymous inner classes(without a name),

Another example

Mouse Example