[PDF] [PDF] The AWT, Applets, and Swing

– No main needed import java applet *; public class BasicGUIApplet extends Applet { public void init( ) { add( 



Previous PDF Next PDF





[PDF] AWT Event Handling

5 Object Computing, Inc AWT Event Handling Simple AWT Example import java awt *; import java awt event *; public class SimpleAWT extends java applet



[PDF] Java Applets Java Applets

CSD Univ of Crete The Simplest Reasonable Ap import java awt *; import java applet Applet; public class HelloWorld extends public void paint( Graphics g ) g



[PDF] Présentation PowerPoint

Le package java awt est encore utilisé pour la gestion d' Les applets Swing sont créées à partir de la classe JApplet JApplet : classe de base des applets



[PDF] The AWT, Applets, and Swing

– No main needed import java applet *; public class BasicGUIApplet extends Applet { public void init( ) { add( 



[PDF] JAVA PROGRAMMING Class - TCET

7 août 2017 · Semester: III Course: IT Subject: JAVA PROGRAMMING Class: SE-A for Library Packages, java util Vector PPT, Chalk Board 28-08- 17 Applet class methods PPT, Chalk Handling, Event Classes, Event Sources 



[PDF] EVENT DRIVEN PROGRAMMING UNIT-5 - Sri Vidya College of

fied font Example: GraphicsDemo java import java applet Applet; import java awt *; public class GraphicsDemo extends Applet{ public void paint(Graphics g){ g



[PDF] OBJECT ORIENTED PROGRAMMING - IARE

In Java, class “Object” is the base class to all other classes – If we do not A good example is the Java hierarchy of Graphical components in the AWT: • Component Concepts of Applets, differences between applets and applications



[PDF] Introduction to JAVA (slides) - Indico

A Java applet is a program designed to be executed under a Java capable browser Page 6 First Latin American Workshop on Distributed Laboratory 



[PDF] CA211 : OBJECT ORIENTED PROGRAMMING THROUGH JAVA

To understand the Event Handling, Applets and AWT • To gain in-depth Herbert Schildt, “Java The Complete Reference”, 9th Edition, McGraw Hill Education

[PDF] event marketing plan template excel

[PDF] eveque de paris au 6eme siecle

[PDF] eveque de paris au vi siecle

[PDF] eveque paris 6eme siecle

[PDF] every finite language is regular proof

[PDF] evolution de la salinité des océans

[PDF] evolution historique du modele de l'atome

[PDF] evolution of new york city skyline

[PDF] évolution prix immobilier paris 2020

[PDF] ex france equipement grande cuisine vente en ligne

[PDF] ex2 4 class 9

[PDF] exalogic solutions wiki

[PDF] exam ifm syllabus 2019

[PDF] exam ref 70 480 programming in html5 with javascript and css3

[PDF] examen algebre s1 smpc corrigés pdf

1

The AWT, Applets, and Swing

Mark Allen Weiss

Copyright 1996, 1999, 2000

2

Outline of Topics

lThe Abstract Window Toolkit -Basic ideas -User interfaces -Output items: canvases and graphics -Events -Fancy layouts lApplets -HTML files -Converting an application to an applet -Restrictions 3

Basic Ideas

lThe Abstract Window Toolkit (AWT) is a GUI toolkit designed to work across multiple platforms. lNot nearly as fancy as MFC. lEvent-driven: the window is displayed, and when things happen, an event handler is called.

Generally, the default event handler is to do

nothing. lMust import java.awt.* and java.awt.event.* 4

Evolution of GUIs

lJava 1.0 -basic AWT components -terrible event model lJava 1.1 -same AWT components -new event model lJava 1.2 -new fancy Swing components -same event model as 1.1 -not supported in all browsers, but plug-in available 5

To Swing or Not?

lIf you are writing applications, Swing is by far the preferable option -faster -prettier -more flexible lIf you are writing applets, decision is harder -consumers not likely to have Java 1.2; can give it to them, but download will be time-consuming. Most consumers won"t bother and will go elsewhere -corporate clients can be forced to go to Java 1.2 6

AWT vs Swing

lConcepts are all the same. lWe will discuss AWT, so applets will work unobtrusively. lSwing talk to follow separately. In this class: -Use Swing for applications. -For applets, consider using HTML forms and server-side servlets. If not, include Swing library in jar file for distribution and hope that user has a fast connection. 7

General Layout of AWT

Component

Container

PanelWindow

Dialog

FileDialog

Frame

Button

Canvas

Checkbox

Choice

Label List

TextArea

TextField

8 lThe parent class of many of the AWT classes. lRepresents something that has a position and a size and can be painted on the screen as well as receive input events. lThis is an abstract class and may not be instantiated. lSome important methods: public void paint( Graphics g ); public void show( ); public void addComponentListener( ComponentListener l ) Various routines to set fonts, handle mouse events, etc.

Component

9

Container

lThe parent class of all components and one that can contain other classes. lHas a useful helper object called a

LayoutManager, which is a class that

positions components inside the container. lSome methods: void setLayout( LayoutManager mgr ); void add( Component comp ); void add( Component comp, String name ); 10

Top Level Windows

lWindow: A top-level window that has no border. lFrame: A top-level window that has a border and can also have an associated MenuBar. lDialog: A top-level window used to create dialogs. One subclass of this is the

FileDialog.

11 Panel lSubclass of Container used inside other containers. lUsed to store collections of objects. lDoes not create a separate window of its own. 12

Important I/O Components

lButton: A push button. lCanvas: General-purpose component that lets you paint or trap input events from the user. It can be used to create graphics. Typically, is subclassed to create a custom component. lCheckbox: A component that has an "on" or "off" state. You can place Checkboxes in a group that allows at most 1 box to be checked. lChoice: A component that allows the selection of one of a group of choices. Takes up little screen space. 13

More I/O Components

lLabel: A component that displays a String at a certain location. lList: A scrolling list of strings. Allows one or several items to be selected. lTextArea: Multiple line text components that allows viewing and editing. lTextField: A single-line text component that can be used to build forms. 14

Events (Java 1.1 World)

lEach component may receive events. lOnly objects that implement an

EventListener interface (e.g.

ActionListener, MouseListener) may

handle the event. The event is handled by a performed method (e.g. actionPerformed) lSuch objects must register, via an addListener, that they will handle the particular event. lIt makes more sense when you see the example. lJava 1.0 had a different, and very poor alternative. 15

Most Common Listeners

lActionListener: button pushes, etc. lKeyListener: keystroke events (pressing, releasing, typing) lMouseListener: mouse events (pressing,releasing, clicking, enter/exit) lMouseMotionListener: mouse moving events (dragging, moving) lTextListener: text in a component changes lWindowListener: window events (closing, iconifying, etc) 16

Event Handler Classes

lEvent handler classes need access to components whose state information might need to be queried or changed lCommon to use inner classes lOften anonymous inner classes used -syntax can look ugly -however, can see what actions will occur more easily when event handler functionality is immediately next to component 17

Adapter Classes

lSome listener interfaces require you to implement several methods -WindowListener has 7! lYou must implement all methods of the interface, not just the ones of interest. lAll listener interfaces with multiple methods have a corresponding Adapter class that implements all methods with empty bodies -so, you just extend the adapter class with methods you are interested in; others get default 18

Making A Frame Close

lWhen frame is closed, WindowEvent is generated; someone should listen and handle windowClosing method. -Java 1.1: otherwise, frame stays open -Java 1.2: otherwise, frame closes, but event thread continues, even if no other visible components -Java 1.3: frame closes, and can make arrangements for event thread to stop if no other visible components 19

Implementing CloseableFrame

quotesdbs_dbs14.pdfusesText_20