Java AWT Windows, Text, & Graphics
|
|
- Ralph Maxwell
- 6 years ago
- Views:
Transcription
1 2 AWT Java AWT Windows, Text, & Graphics The Abstract Windows Toolkit (AWT) contains numerous classes and methods that allow you to create and manage applet windows and standard windows that run in a GUI environment, such as Windows The AWT classes are contained in the java.awt package. 3 4 Window Fundamentals AWT class Hierarchy The AWT defines windows based on a class hierarchy that adds functionality at each level. The two most common windows are those derived from Panel used by applets and Frame that creates standard windows. 5 6 AWT class Hierarchy Component is an abstract class that encapsulates all all of the user interface elements that are displayed on the screen and that interact with the user. The container class is an abstract subclass of Component. The class is responsible for laying out any components it contains through using various layout managers. AWT class Hierarchy The Panel class is a concrete subclass of Container. When screen output is directed to an applet, it is drawn on the surface of a Panel object. In essence, a Panel is a window that does not contain a title bar, menu bar, or border.
2 7 8 AWT class Hierarchy Frame encapsulates what is commonly thought of as a window. It is a subclass of Window and has a title bar, menu bar, borders, and resizing corners. When a Frame window is created from within an applet window, warning message will produced. When a Frame window is created by a program, a normal window is created. Frame Windows Frame supports two constructors: Frame() & Frame(String title) You cannot specify the dimensions of the window. Instead, you must set the size after the window has been created by using the following two methods: void resize(int newwidth, int newheight) void resize(dimension newsize) 9 10 Frame Windows Once a Frame window is created, it will not be visible until you call show(). To hide a window, call hide(). To set new title, use settitle(string newtitle). import java.awt.*; public class BoringFrame1 { Using Class Frame Create a new JFrame public static void main(string[] args) { Frame test = new Frame("A Boring Frame"); Set its dimensions test.setsize(300,200); Set its position test.setlocation(100,200); test.setbackground(color.white); test.show(); Set its background colour Make it visible on the screen import java.awt.*; public class BoringFrame2 extends Frame { public BoringFrame2() { super( Ishbel"); this.setsize(400,100); this.setlocation(100,200); this.setbackground(color.cyan); this.setvisible(true); public static void main(string[] args) { BoringFrame2 test = new BoringFrame2(); Another Frame Eventi Evento: qualcosa che l utente fa sulla interfaccia grafica Cliccare su un pulsante, scrivere in un campo. Ogni evento coinvolge tre oggetti La sorgente, ossia l oggetto che ha causato l evento (es. il pulsante cliccato) L evento, anch esso rappresentato come un oggetto (es. ActionEvent, clic di un pulsante) Il listener, ossia l oggetto che deve rispondere all evento
3 13 14 Oggetto listener Per gestire gli eventi è necessario implementare un listener Esempio: public class MyApplication implements ActionListener { Gestire gli eventi Il listener deve trattare il messaggio actionperformed public void actionperformed(actionevent ae) La sorgente (controllo gui) deve sapere quale oggetto gestirà gli eventi da essa prodotti (listener) calcbutton.addactionlistener(this); Metodo actionperformed public void actionperformed(actionevent event) { String name = namefield.gettext(); int rate = Integer.parseInt(rateField.getText()); Employee e = new Employee(name, rate); int hours = Integer.parseInt(hoursField.getText()); int pay = e.calcpay(hours); String result = e.getname().concat(" earned $"). concat(integer.tostring(pay)); resultlabel.settext(result); dolayout(); 15 import java.awt.*; import java.awt.event.windowevent; import java.awt.event.windowlistener; public class BoringFrame3 implements WindowListener { private Frame test; Evento WindowClosing public BoringFrame3() { test = new Frame("Closeable Frame"); test.setsize(300,200); test.setlocation(100,200); test.setbackground(color.white); test.show(); test.addwindowlistener(this); public static void main(string[] args) { BoringFrame3 app = new BoringFrame3(); public void windowclosing(windowevent we) { test.hide(); System.exit(0); Controls Java AWT Controls Layout Managers Menus The AWT supports the following types of control subclasses of Component: Labels Buttons Check boxes Check box groups Drop-down menus Lists Scroll bars Text editing
4 19 20 Controls & Events Except for labels, all other controls generate events. To handle control-generated events, your program must implements the related listener interface. ActionListener AdjustmentListener AWTEventListener ComponentListener ContainerListener FocusListener HierarchyBoundsListener HierarchyListener InputMethodListener ItemListener KeyListener MouseListener MouseMotionListener MouseWheelListener TextListener WindowFocusListener WindowListener WindowStateListener Listener Interfaces The listener interface for receiving action events. The listener interface for receiving adjustment events. The listener interface for receiving notification of events dispatched to objects that are instances of Component or MenuComponent or their subclasses. The listener interface for receiving component events. The listener interface for receiving container events. The listener interface for receiving keyboard focus events on a component. The listener interface for receiving ancestor moved and resized events. The listener interface for receiving hierarchy changed events. The listener interface for receiving input method events. The listener interface for receiving item events. The listener interface for receiving keyboard events (keystrokes). The listener interface for receiving "interesting" mouse events (press, release, click, enter, and exit) on a component. The listener interface for receiving mouse motion events on a component. The listener interface for receiving mouse wheel events on a component. The listener interface for receiving text events. The listener interface for receiving WindowEvents, including WINDOW_GAINED_FOCUS and WINDOW_LOST_FOCUS events. The listener interface for receiving window events. The listener interface for receiving window state events Events Controls & Events ActionEvent AdjustmentEvent AWTEventListenerPro xy ComponentEvent ContainerAdapter ContainerEvent FocusEvent HierarchyBoundsAdap ter HierarchyEvent InputEvent InputMethodEvent InvocationEvent ItemEvent KeyEvent MouseEvent MouseWheelEvent PaintEvent TextEvent WindowEvent A semantic event which indicates that a component-defined action occured. The adjustment event emitted by Adjustable objects. A class which extends the EventListenerProxy, specifically for adding an AWTEventListener for a specific event mask. A low-level event which indicates that a component moved, changed size, or changed visibility (also, the root class for the other component-level events). An abstract adapter class for receiving container events. A low-level event which indicates that a container's contents changed because a component was added or removed. A low-level event which indicates that a Component has gained or lost the input focus. An abstract adapter class for receiving ancestor moved and resized events. An event which indicates a change to the Component hierarchy to which a Component belongs. The root event class for all component-level input events. Input method events contain information about text that is beingcomposed using an input method. An event which executes the run() method on a Runnablewhen dispatched by the AWT event dispatcher thread. A semantic event which indicates that an item was selected or deselected. An event which indicates that a keystroke occurred in a component. An event which indicates that a mouse action occurred in a component. An event which indicates that the mouse wheel was rotated in a component. The component-level paint event. A semantic event which indicates that an object's text changed. A low-level event that indicates that a window has changed its status. The Event class defines several fields and constants for event handling. The two most important fields are source, which contains a reference to the object that generates the event, and id, which contains the constant that identifies the event. Other event specific information are available Labels Label contains a string which it displays. Label defines 3 constructors: Label() Label(String str) Label(String str, int alignment) The string in a label can be changed by settext() and abstracted by gettext(). Buttons A button contains a label and generates an event when it is pressed. A button can created by: Button() or Button(String labelstr) or Button listname[] = new Button[#ofelement] The label string can be changed by setlabel() and retrieved by getlabel().
5 25 26 Check Boxes Check Boxes A check box is associated with a label and a state of either checked or unchecked. Check boxes are objects of the Checkbox class and can be created by: Checkbox() Checkbox(String labelstr) Checkbox(String labelstr, CheckboxGroup groupname, boolean on) Use getstate() to retrieve the current state of a check box and setstate() to set its state. Use getlabel() to retrieve the current label and setlabel() to set the label Check Box Group The CheckboxGroup contains a set of mutually exclusive check boxes which are often called ratio buttons. CheckboxGroup() Checkbox(labelName, groupname, boolean on) The getcurrent() method returns the check box being checked and the setcurrent() method sets a check box. Choice The Choice class creates a pop-up list of items. Each item is a string that appears as a left-justified label in the order it is added. Choice only defines the default constructor, which creates an empty line. To add an item, use additem(): additem(string name) Choice Choice To retrieve the item being currently selected, use String getselecteditem() or int getselectindex(). To obtain the number of items in the list, use int countitems(). To set a selected item, use void select(int index) or void select(string name) To retrieve the name of an item at an index, use String getitem(int index)
6 31 32 List List The List class provides a compact, multiple-choice, scrolling selection list. List provides two constructors: List() List(int numrows, boolean multipleselect) To add a selection, use additem(). List selections are to be double-clicked. For lists with only one selection, current item selected can be retrieved by using String getselecteditem() or int getselectedindex() For lists with multiple selections, use String[] getselecteditems() or int[] getselectedindexes() TextField The TextField class implements a single-line text-entry area that allowss the user to enter strings, edit the string using the arrow keys, cut and paste keys, and mouse selections TextField has four constructors: TextField() TextField(int numchars) TextField(String str) TextField(String str, int numchars) TextField Use gettext() to get current string store in the text field; use settext() to set the the text. To retrieve a portion of the text, use void select(int startindex, int endindex) To control the modifiability of the text field, use seteditable() Containers A Container is a GUI elements that hold other components (containers and controls) Each Container object has a layout manager associated with it. Layout Manager A layout manager is an object responsible of GUI components disposition A layout manager is an instance of any class that implements the LayoutManager interface. The layout manager is set by the setlayout() method. If no call is made to setlayout() is made, the default layout manager is used.
7 37 38 Layout Manager Whenever a container is resized, the layout manager is used to position each of the components within it. Each layout manager keeps track of a list of components that are stored by their names. The layout manager automatically rearranges the layout of its components. Layout Manager FlowLayout BorderLayout GridLayout CardLayout GridBagLayout FlowLayout BorderLayout GridLayout CardLayout colonne righe
8 43 44 GridBagLayout Riferimenti La documentazione java Packages: java.awt java.awt.event
Module 4 Multi threaded Programming, Event Handling. OOC 4 th Sem, B Div Prof. Mouna M. Naravani
Module 4 Multi threaded Programming, Event Handling OOC 4 th Sem, B Div 2017-18 Prof. Mouna M. Naravani Event Handling Complete Reference 7 th ed. Chapter No. 22 Event Handling Any program that uses a
More informationOBJECT ORIENTED PROGRAMMING. Java GUI part 1 Loredana STANCIU Room B616
OBJECT ORIENTED PROGRAMMING Java GUI part 1 Loredana STANCIU loredana.stanciu@upt.ro Room B616 What is a user interface That part of a program that interacts with the user of the program: simple command-line
More informationProgramming Mobile Devices J2SE GUI
Programming Mobile Devices J2SE GUI University of Innsbruck WS 2009/2010 thomas.strang@sti2.at Graphical User Interface (GUI) Why is there more than one Java GUI toolkit? AWT write once, test everywhere
More information11/7/12. Discussion of Roulette Assignment. Objectives. Compiler s Names of Classes. GUI Review. Window Events
Objectives Event Handling Animation Discussion of Roulette Assignment How easy/difficult to refactor for extensibility? Was it easier to add to your refactored code? Ø What would your refactored classes
More informationAdvanced Java Programming (17625) Event Handling. 20 Marks
Advanced Java Programming (17625) Event Handling 20 Marks Specific Objectives To write event driven programs using the delegation event model. To write programs using adapter classes & the inner classes.
More informationSD Module-1 Advanced JAVA
Assignment No. 4 SD Module-1 Advanced JAVA R C (4) V T Total (10) Dated Sign Title: Transform the above system from command line system to GUI based application Problem Definition: Write a Java program
More informationSD Module-1 Advanced JAVA. Assignment No. 4
SD Module-1 Advanced JAVA Assignment No. 4 Title :- Transform the above system from command line system to GUI based application Problem Definition: Write a Java program with the help of GUI based Application
More informationGUI DYNAMICS Lecture July 26 CS2110 Summer 2011
GUI DYNAMICS Lecture July 26 CS2110 Summer 2011 GUI Statics and GUI Dynamics 2 Statics: what s drawn on the screen Components buttons, labels, lists, sliders, menus,... Containers: components that contain
More informationUNIT-3 : MULTI THREADED PROGRAMMING, EVENT HANDLING. A Multithreaded program contains two or more parts that can run concurrently.
UNIT-3 : MULTI THREADED PROGRAMMING, EVENT HANDLING 1. What are Threads? A thread is a single path of execution of code in a program. A Multithreaded program contains two or more parts that can run concurrently.
More informationCSE 143. Event-driven Programming and Graphical User Interfaces (GUIs) with Swing/AWT
CSE 143 Event-driven Programming and Graphical User Interfaces (GUIs) with Swing/AWT slides created by Marty Stepp based on materials by M. Ernst, S. Reges, D. Notkin, R. Mercer, Wikipedia http://www.cs.washington.edu/331/
More informationControl Flow: Overview CSE3461. An Example of Sequential Control. Control Flow: Revisited. Control Flow Paradigms: Reacting to the User
CSE3461 Control Flow Paradigms: Reacting to the User Control Flow: Overview Definition of control flow: The sequence of execution of instructions in a program. Control flow is determined at run time by
More informationThe AWT Event Model 9
The AWT Event Model 9 Course Map This module covers the event-based GUI user input mechanism. Getting Started The Java Programming Language Basics Identifiers, Keywords, and Types Expressions and Flow
More informationJava Graphical User Interfaces AWT (Abstract Window Toolkit) & Swing
Java Graphical User Interfaces AWT (Abstract Window Toolkit) & Swing Rui Moreira Some useful links: http://java.sun.com/docs/books/tutorial/uiswing/toc.html http://www.unix.org.ua/orelly/java-ent/jfc/
More informationGUI in Java TalentHome Solutions
GUI in Java TalentHome Solutions AWT Stands for Abstract Window Toolkit API to develop GUI in java Has some predefined components Platform Dependent Heavy weight To use AWT, import java.awt.* Calculator
More informationGUI Programming: Swing and Event Handling
GUI Programming: Swing and Event Handling Sara Sprenkle 1 Announcements No class next Tuesday My Fourth of July present to you: No quiz! Assignment 3 due today Review Collections: List, Set, Map Inner
More informationInteracción con GUIs
Interacción con GUIs Delegation Event Model Fuente EVENTO Oyente suscripción Fuente Oyente suscripción EVENTO Adaptador EVENTO java.lang.object java.util.eventobject java.awt.awtevent java.awt.event. ActionEvent
More informationCSE 331. Event-driven Programming and Graphical User Interfaces (GUIs) with Swing/AWT
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. Reges, D. Notkin, R. Mercer, Wikipedia http://www.cs.washington.edu/331/
More informationExample Programs. COSC 3461 User Interfaces. GUI Program Organization. Outline. DemoHelloWorld.java DemoHelloWorld2.java DemoSwing.
COSC User Interfaces Module 3 Sequential vs. Event-driven Programming Example Programs DemoLargestConsole.java DemoLargestGUI.java Demo programs will be available on the course web page. GUI Program Organization
More informationTable of Contents. Chapter 1 Getting Started with Java SE 7 1. Chapter 2 Exploring Class Members in Java 15. iii. Introduction of Java SE 7...
Table of Contents Chapter 1 Getting Started with Java SE 7 1 Introduction of Java SE 7... 2 Exploring the Features of Java... 3 Exploring Features of Java SE 7... 4 Introducing Java Environment... 5 Explaining
More informationGUI Program Organization. Sequential vs. Event-driven Programming. Sequential Programming. Outline
Sequential vs. Event-driven Programming Reacting to the user GUI Program Organization Let s digress briefly to examine the organization of our GUI programs We ll do this in stages, by examining three example
More informationGUI Design. Overview of Part 1 of the Course. Overview of Java GUI Programming
GUI Design Michael B. Spring Department of Information Science and Telecommunications University of Pittsburgh spring@imap.pitt.edu http://www.sis.pitt.edu /~spring Overview of Part 1 of the Course Demystifying
More informationGUI and its COmponent Textfield, Button & Label. By Iqtidar Ali
GUI and its COmponent Textfield, Button & Label By Iqtidar Ali GUI (Graphical User Interface) GUI is a visual interface to a program. GUI are built from GUI components. A GUI component is an object with
More informationCourse Status Networking GUI Wrap-up. CS Java. Introduction to Java. Andy Mroczkowski
CS 190 - Java Introduction to Java Andy Mroczkowski uamroczk@cs.drexel.edu Department of Computer Science Drexel University March 10, 2008 / Lecture 8 Outline Course Status Course Information & Schedule
More informationMobile MOUSe JAVA2 FOR PROGRAMMERS ONLINE COURSE OUTLINE
Mobile MOUSe JAVA2 FOR PROGRAMMERS ONLINE COURSE OUTLINE COURSE TITLE JAVA2 FOR PROGRAMMERS COURSE DURATION 14 Hour(s) of Interactive Training COURSE OVERVIEW With the Java2 for Programmers course, anyone
More informationG51PRG: Introduction to Programming Second semester Applets and graphics
G51PRG: Introduction to Programming Second semester Applets and graphics Natasha Alechina School of Computer Science & IT nza@cs.nott.ac.uk Previous two lectures AWT and Swing Creating components and putting
More informationBM214E Object Oriented Programming Lecture 13
BM214E Object Oriented Programming Lecture 13 Events To understand how events work in Java, we have to look closely at how we use GUIs. When you interact with a GUI, there are many events taking place
More informationCSE 331. Event- driven Programming and Graphical User Interfaces (GUIs) with Swing/AWT
CSE 331 Event- driven Programming and Graphical User Interfaces (GUIs) with Swing/AWT Lecturer: Michael Hotan slides created by Marty Stepp based on materials by M. Ernst, S. Reges, D. Notkin, R. Mercer,
More informationIntroduction to the JAVA UI classes Advanced HCI IAT351
Introduction to the JAVA UI classes Advanced HCI IAT351 Week 3 Lecture 1 17.09.2012 Lyn Bartram lyn@sfu.ca About JFC and Swing JFC Java TM Foundation Classes Encompass a group of features for constructing
More informationPackages: Putting Classes Together
Packages: Putting Classes Together 1 Introduction 2 The main feature of OOP is its ability to support the reuse of code: Extending the classes (via inheritance) Extending interfaces The features in basic
More informationกล ม API ท ใช. Programming Graphical User Interface (GUI) Containers and Components 22/05/60
กล ม API ท ใช Programming Graphical User Interface (GUI) AWT (Abstract Windowing Toolkit) และ Swing. AWT ม ต งต งแต JDK 1.0. ส วนมากจะเล กใช และแทนท โดยr Swing components. Swing API ปร บปร งความสามารถเพ
More information14.2 Java s New Nimbus Look-and-Feel 551 Sample GUI: The SwingSet3 Demo Application As an example of a GUI, consider Fig. 14.1, which shows the SwingS
550 Chapter 14 GUI Components: Part 1 14.1 Introduction 14.2 Java s New Nimbus Look-and-Feel 14.3 Simple GUI-Based Input/Output with JOptionPane 14.4 Overview of Swing Components 14.5 Displaying Text and
More informationSri Vidya College of Engineering & Technology
UNIT-V TWO MARKS QUESTION & ANSWER 1. What is the difference between the Font and FontMetrics class? Font class is used to set or retrieve the screen fonts.the Font class maps the characters of the language
More informationPROGRAMMING DESIGN USING JAVA (ITT 303) Unit 7
PROGRAMMING DESIGN USING JAVA (ITT 303) Graphical User Interface Unit 7 Learning Objectives At the end of this unit students should be able to: Build graphical user interfaces Create and manipulate buttons,
More informationAll the Swing components start with J. The hierarchy diagram is shown below. JComponent is the base class.
Q1. If you add a component to the CENTER of a border layout, which directions will the component stretch? A1. The component will stretch both horizontally and vertically. It will occupy the whole space
More informationCOMPSCI 230. Software Design and Construction. Swing
COMPSCI 230 Software Design and Construction Swing 1 2013-04-17 Recap: SWING DESIGN PRINCIPLES 1. GUI is built as containment hierarchy of widgets (i.e. the parent-child nesting relation between them)
More informationPreviously, we have seen GUI components, their relationships, containers, layout managers. Now we will see how to paint graphics on GUI components
CS112-Section2 Hakan Guldas Burcin Ozcan Meltem Kaya Muge Celiktas Notes of 6-8 May Graphics Previously, we have seen GUI components, their relationships, containers, layout managers. Now we will see how
More informationCS 251 Intermediate Programming GUIs: Event Listeners
CS 251 Intermediate Programming GUIs: Event Listeners Brooke Chenoweth University of New Mexico Fall 2017 What is an Event Listener? A small class that implements a particular listener interface. Listener
More informationDr. Hikmat A. M. AbdelJaber
Dr. Hikmat A. M. AbdelJaber GUI are event driven (i.e. when user interacts with a GUI component, the interaction (event) derives the program to perform a task). Event: click button, type in text field,
More informationGUI Event Handlers (Part I)
GUI Event Handlers (Part I) 188230 Advanced Computer Programming Asst. Prof. Dr. Kanda Runapongsa Saikaew (krunapon@kku.ac.th) Department of Computer Engineering Khon Kaen University 1 Agenda General event
More informationWindow Interfaces Using Swing Objects
Chapter 12 Window Interfaces Using Swing Objects Event-Driven Programming and GUIs Swing Basics and a Simple Demo Program Layout Managers Buttons and Action Listeners Container Classes Text I/O for GUIs
More informationJava Control Fundamentals
Java Control Fundamentals This article continues our exploration of the Abstract Window Toolkit (AWT). It examines the standard controls defined by Java. Controls are components that allow a user to interact
More informationThe Abstract Window Toolkit
Chapter 12 The Abstract Window Toolkit 1 12.1 Overview Java s Abstract Window Toolkit provides classes and other tools for building programs that have a graphical user interface. The term Abstract refers
More informationGraphical Interfaces
Weeks 9&11 Graphical Interfaces All the programs that you have created until now used a simple command line interface, which is not user friendly, so a Graphical User Interface (GUI) should be used. The
More informationGraphical Interfaces
Weeks 11&12 Graphical Interfaces All the programs that you have created until now used a simple command line interface, which is not user friendly, so a Graphical User Interface (GUI) should be used. The
More informationCHAPTER 2. Java Overview
Networks and Internet Programming (0907522) CHAPTER 2 Java Overview Instructor: Dr. Khalid A. Darabkh Objectives The objectives of this chapter are: To discuss the classes present in the java.awt package
More informationGraphical User Interfaces. Comp 152
Graphical User Interfaces Comp 152 Procedural programming Execute line of code at a time Allowing for selection and repetition Call one function and then another. Can trace program execution on paper from
More informationJava. GUI building with the AWT
Java GUI building with the AWT AWT (Abstract Window Toolkit) Present in all Java implementations Described in most Java textbooks Adequate for many applications Uses the controls defined by your OS therefore
More informationBASICS OF GRAPHICAL APPS
CSC 2014 Java Bootcamp Lecture 7 GUI Design BASICS OF GRAPHICAL APPS 2 Graphical Applications So far we ve focused on command-line applications, which interact with the user using simple text prompts In
More informationJava & Graphical User Interface II. Wang Yang wyang AT njnet.edu.cn
Java & Graphical User Interface II Wang Yang wyang AT njnet.edu.cn Outline Review of GUI (first part) What is Event Basic Elements of Event Programming Secret Weapon - Inner Class Full version of Event
More informationHandout 14 Graphical User Interface (GUI) with Swing, Event Handling
Handout 12 CS603 Object-Oriented Programming Fall 15 Page 1 of 12 Handout 14 Graphical User Interface (GUI) with Swing, Event Handling The Swing library (javax.swing.*) Contains classes that implement
More information12/22/11. Copyright by Pearson Education, Inc. All Rights Reserved.
} Radio buttons (declared with class JRadioButton) are similar to checkboxes in that they have two states selected and not selected (also called deselected). } Radio buttons normally appear as a group
More informationWindow Interfaces Using Swing Objects
Chapter 12 Window Interfaces Using Swing Objects Event-Driven Programming and GUIs Swing Basics and a Simple Demo Program Layout Managers Buttons and Action Listeners Container Classes Text I/O for GUIs
More informationEvent Driven Programming
Event Driven Programming 1. Objectives... 2 2. Definitions... 2 3. Event-Driven Style of Programming... 2 4. Event Polling Model... 3 5. Java's Event Delegation Model... 5 6. How to Implement an Event
More informationAssignment No 2. Year: Dept.: ComputerTech. Sanjivani Rural Education Society s Sanjivani KBP Polytechnic, Kopargaon
Year: 015-16 ACAD/F/3 Subject: AJP(1765) Division:CMTA(CM6G) Pages: 1-7 CHAPTER :Event Handling(0 Marks) Q.1 package contains all the classes and methods required for Event handling in java. (a) java.applet
More informationCONTENTS. Chapter 1 Getting Started with Java SE 6 1. Chapter 2 Exploring Variables, Data Types, Operators and Arrays 13
CONTENTS Chapter 1 Getting Started with Java SE 6 1 Introduction of Java SE 6... 3 Desktop Improvements... 3 Core Improvements... 4 Getting and Installing Java... 5 A Simple Java Program... 10 Compiling
More informationFrames, GUI and events. Introduction to Swing Structure of Frame based applications Graphical User Interface (GUI) Events and event handling
Frames, GUI and events Introduction to Swing Structure of Frame based applications Graphical User Interface (GUI) Events and event handling Introduction to Swing The Java AWT (Abstract Window Toolkit)
More informationUnit - 2 Abstract Window Toolkit
Abstract Window Toolkit: (AWT) Java AWT is an API to develop GUI or window-based application in java. Java AWT provides many of user interface objects are called Components of the Java AWT. Java AWT components
More informationChapter 1 GUI Applications
Chapter 1 GUI Applications 1. GUI Applications So far we've seen GUI programs only in the context of Applets. But we can have GUI applications too. A GUI application will not have any of the security limitations
More informationBasicsof. JavaGUI and SWING
Basicsof programming3 JavaGUI and SWING GUI basics Basics of programming 3 BME IIT, Goldschmidt Balázs 2 GUI basics Mostly window-based applications Typically based on widgets small parts (buttons, scrollbars,
More informationOutline. Topic 9: Swing. GUIs Up to now: line-by-line programs: computer displays text user types text AWT. A. Basics
Topic 9: Swing Outline Swing = Java's GUI library Swing is a BIG library Goal: cover basics give you concepts & tools for learning more Assignment 7: Expand moving shapes from Assignment 4 into game. "Programming
More informationThe Abstract Windowing Toolkit. Java Foundation Classes. Swing. In April 1997, JavaSoft announced the Java Foundation Classes (JFC).
The Abstract Windowing Toolkit Since Java was first released, its user interface facilities have been a significant weakness The Abstract Windowing Toolkit (AWT) was part of the JDK form the beginning,
More informationCSC207H: Software Design Lecture 11
CSC207H: Software Design Lecture 11 Wael Aboelsaadat wael@cs.toronto.edu http://ccnet.utoronto.ca/20075/csc207h1y/ Office: BA 4261 Office hours: R 5-7 Acknowledgement: These slides are based on material
More informationTopic 9: Swing. Swing is a BIG library Goal: cover basics give you concepts & tools for learning more
Swing = Java's GUI library Topic 9: Swing Swing is a BIG library Goal: cover basics give you concepts & tools for learning more Assignment 5: Will be an open-ended Swing project. "Programming Contest"
More informationTopic 9: Swing. Why are we studying Swing? GUIs Up to now: line-by-line programs: computer displays text user types text. Outline. 1. Useful & fun!
Swing = Java's GUI library Topic 9: Swing Swing is a BIG library Goal: cover basics give you concepts & tools for learning more Why are we studying Swing? 1. Useful & fun! 2. Good application of OOP techniques
More informationChapter 6: Graphical User Interfaces
Chapter 6: Graphical User Interfaces CS 121 Department of Computer Science College of Engineering Boise State University April 21, 2015 Chapter 6: Graphical User Interfaces CS 121 1 / 36 Chapter 6 Topics
More informationChapter 8. Java continued. CS Hugh Anderson s notes. Page number: 264 ALERT. MCQ test next week. This time. This place.
Chapter 8 Java continued CS3283 - Hugh Anderson s notes. Page number: 263 ALERT MCQ test next week This time This place Closed book CS3283 - Hugh Anderson s notes. Page number: 264 ALERT Assignment #2
More informationStarting Out with Java: From Control Structures Through Objects Sixth Edition
Starting Out with Java: From Control Structures Through Objects Sixth Edition Chapter 12 A First Look at GUI Applications Chapter Topics 12.1 Introduction 12.2 Creating Windows 12.3 Equipping GUI Classes
More informationJava continued. Chapter 8 ALERT ALERT. Last week. MCQ test next week. This time. This place. Closed book. Assignment #2 is for groups of 3
Chapter 8 Java continued MCQ test next week This time This place Closed book ALERT CS3283 - Hugh Anderson s notes. Page number: 263 CS3283 - Hugh Anderson s notes. Page number: 264 ALERT Last week Assignment
More informationGraphics. Lecture 18 COP 3252 Summer June 6, 2017
Graphics Lecture 18 COP 3252 Summer 2017 June 6, 2017 Graphics classes In the original version of Java, graphics components were in the AWT library (Abstract Windows Toolkit) Was okay for developing simple
More informationGUI Event Handling 11. GUI Event Handling. Objectives. What is an Event? Hierarchical Model (JDK1.0) Delegation Model (JDK1.1)
Objectives Write code to handle events that occur in a GUI 11 GUI Event Handling Describe the concept of adapter classes, including how and when to use them Determine the user action that originated the
More informationHandling Mouse and Keyboard Events
Handling Mouse and Keyboard Events 605.481 1 Java Event Delegation Model EventListener handleevent(eventobject handleevent(eventobject e); e); EventListenerObject source.addlistener(this);
More informationAWT WINDOW CLASS. The class Window is a top level window with no border and no menubar. It uses BorderLayout as default layout manager.
http://www.tutorialspoint.com/awt/awt_window.htm AWT WINDOW CLASS Copyright tutorialspoint.com Introduction The class Window is a top level window with no border and no menubar. It uses BorderLayout as
More informationGraphical User Interfaces in Java - SWING
Graphical User Interfaces in Java - SWING Graphical User Interfaces (GUI) Each graphical component that the user can see on the screen corresponds to an object of a class Component: Window Button Menu...
More informationCSEN401 Computer Programming Lab. Topics: Graphical User Interface Window Interfaces using Swing
CSEN401 Computer Programming Lab Topics: Graphical User Interface Window Interfaces using Swing Prof. Dr. Slim Abdennadher 22.3.2015 c S. Abdennadher 1 Swing c S. Abdennadher 2 AWT versus Swing Two basic
More informationComputer Programming Java AWT Lab 18
Computer Programming Java AWT Lab 18 엄현상 (Eom, Hyeonsang) School of Computer Science and Engineering Seoul National University Copyrights 2015 DCSLab. All Rights Reserved Overview AWT Basic Use AWT AWT
More informationMarcin Luckner Warsaw University of Technology Faculty of Mathematics and Information Science
Marcin Luckner Warsaw University of Technology Faculty of Mathematics and Information Science mluckner@mini.pw.edu.pl http://www.mini.pw.edu.pl/~lucknerm } Abstract Window Toolkit Delegates creation and
More informationThis exam is closed textbook(s) and closed notes. Use of any electronic device (e.g., for computing and/or communicating) is NOT permitted.
York University AS/AK/ITEC 2610 3.0 All Sections OBJECT-ORIENTED PROGRAMMING Midterm Test Duration: 90 Minutes This exam is closed textbook(s) and closed notes. Use of any electronic device (e.g., for
More informationAWT CHOICE CLASS. Choice control is used to show pop up menu of choices. Selected choice is shown on the top of the menu.
http://www.tutorialspoint.com/awt/awt_choice.htm AWT CHOICE CLASS Copyright tutorialspoint.com Introduction Choice control is used to show pop up menu of choices. Selected choice is shown on the top of
More informationJava Applets / Flash
Java Applets / Flash Java Applet vs. Flash political problems with Microsoft highly portable more difficult development not a problem less so excellent visual development tool Applet / Flash good for:
More informationProgramming Languages and Techniques (CIS120e)
Programming Languages and Techniques (CIS120e) Lecture 29 Nov. 19, 2010 Swing I Event- driven programming Passive: ApplicaHon waits for an event to happen in the environment When an event occurs, the applicahon
More informationCS 251 Intermediate Programming GUIs: Components and Layout
CS 251 Intermediate Programming GUIs: Components and Layout Brooke Chenoweth University of New Mexico Fall 2017 import javax. swing.*; Hello GUI public class HelloGUI extends JFrame { public HelloGUI ()
More informationProgramming graphics
Programming graphics Need a window javax.swing.jframe Several essential steps to use (necessary plumbing ): Set the size width and height in pixels Set a title (optional), and a close operation Make it
More informationAWT CHECKBOX CLASS. Creates a check box with the specified label and sets the specified state.
http://www.tutorialspoint.com/awt/awt_checkbox.htm AWT CHECKBOX CLASS Copyright tutorialspoint.com Introduction Checkbox control is used to turn an option ontrue or offfalse. There is label for each checkbox
More informationJonathan Aldrich Charlie Garrod
Principles of Software Construction: Objects, Design, and Concurrency (Part 3: Design Case Studies) Introduction to GUIs Jonathan Aldrich Charlie Garrod School of Computer Science 1 Administrivia Homework
More informationOverloading Example. Overloading. When to Overload. Overloading Example (cont'd) (class Point continued.)
Overloading Each method has a signature: its name together with the number and types of its parameters Methods Signatures String tostring() () void move(int dx,int dy) (int,int) void paint(graphicsg) (Graphics)
More informationJAVA PROGRAMMING COURSE NO. IT-705(A) SECTION - A
Q1. Define the following terms: JAVA PROGRAMMING COURSE NO. IT-705(A) SECTION - A i. Event An event in Java is an object that is created when something changes within a graphical user interface. If a user
More information7. Program Frameworks
7. Program Frameworks Overview: 7.1 Introduction to program frameworks 7.2 Program frameworks for User Interfaces: - Architectural properties of GUIs - Abstract Window Toolkit of Java Many software systems
More informationCS11 Java. Fall Lecture 4
CS11 Java Fall 2006-2007 Lecture 4 Today s Topics Interfaces The Swing API Event Handlers Inner Classes Arrays Java Interfaces Classes can only have one parent class No multiple inheritance in Java! By
More informationUNIT - 6 AWT SWINGS [ABSTARCT WINDOW TOOLKIT]
UNIT - 6 AWT [ABSTARCT WINDOW TOOLKIT] SWINGS Introduction to AWT AWT (Abstract Window Toolkit) was Java s first GUI framework, which was introduced in Java 1.0. It is used to create GUIs (Graphical User
More informationJava: Graphical User Interfaces (GUI)
Chair of Software Engineering Carlo A. Furia, Marco Piccioni, and Bertrand Meyer Java: Graphical User Interfaces (GUI) With material from Christoph Angerer The essence of the Java Graphics API Application
More informationJAVA. Object Oriented Programming with. M.T. Somashekara D.S.Guru K.S. Manjunatha
PH IL ea rn in g C op yr ig ht ed JAVA M at er ia l Object Oriented Programming with M.T. Somashekara D.S.Guru K.S. Manjunatha Object Oriented Programming with JAVA M.T. SOMASHEKARA Department of Computer
More informationCS11 Java. Fall Lecture 3
CS11 Java Fall 2014-2015 Lecture 3 Today s Topics! Class inheritance! Abstract classes! Polymorphism! Introduction to Swing API and event-handling! Nested and inner classes Class Inheritance! A third of
More informationJava Swing. based on slides by: Walter Milner. Java Swing Walter Milner 2005: Slide 1
Java Swing based on slides by: Walter Milner Java Swing Walter Milner 2005: Slide 1 What is Swing? A group of 14 packages to do with the UI 451 classes as at 1.4 (!) Part of JFC Java Foundation Classes
More informationProgramming Language Concepts: Lecture 8
Programming Language Concepts: Lecture 8 Madhavan Mukund Chennai Mathematical Institute madhavan@cmi.ac.in http://www.cmi.ac.in/~madhavan/courses/pl2009 PLC 2009, Lecture 8, 11 February 2009 GUIs and event
More informationDatenbank-Praktikum. Universität zu Lübeck Sommersemester 2006 Lecture: Swing. Ho Ngoc Duc 1
Datenbank-Praktikum Universität zu Lübeck Sommersemester 2006 Lecture: Swing Ho Ngoc Duc 1 Learning objectives GUI applications Font, Color, Image Running Applets as applications Swing Components q q Text
More informationGraphical User Interface (GUI)
Graphical User Interface (GUI) An example of Inheritance and Sub-Typing 1 Java GUI Portability Problem Java loves the idea that your code produces the same results on any machine The underlying hardware
More informationThe AWT Package, An Overview
Richard G Baldwin (512) 223-4758, baldwin@austin.cc.tx.us, http://www2.austin.cc.tx.us/baldwin/ The AWT Package, An Overview Java Programming, Lecture Notes # 110, Revised 02/21/98. Preface Introduction
More informationAWT LIST CLASS. The List represents a list of text items. The list can be configured to that user can choose either one item or multiple items.
http://www.tutorialspoint.com/awt/awt_list.htm AWT LIST CLASS Copyright tutorialspoint.com Introduction The List represents a list of text items. The list can be configured to that user can choose either
More informationSwing from A to Z Some Simple Components. Preface
By Richard G. Baldwin baldwin.richard@iname.com Java Programming, Lecture Notes # 1005 July 31, 2000 Swing from A to Z Some Simple Components Preface Introduction Sample Program Interesting Code Fragments
More informationGraphic User Interfaces. - GUI concepts - Swing - AWT
Graphic User Interfaces - GUI concepts - Swing - AWT 1 What is GUI Graphic User Interfaces are used in programs to communicate more efficiently with computer users MacOS MS Windows X Windows etc 2 Considerations
More information