Chapter 15

The Abstract Window Toolkit (AWT) Package

by Debasis Samnata


CONTENTS

Introduction

The java.awt Package provides an integrated set of classes and interfaces that manages standard graphical user interface (GUI). It contains GUI components such as buttons, lists, menus, and text areas. In addition to these , it also includes containers such as windows, menu bars etc. and higher level components such as diolog boxes, check boxes, scroll bars etc. The AWT contains two more packages : java.awt.image and java.awt.peer. These two packages will be presented in Chapter 21 and Chapter 22 respectively. The various constituents in the java.awt package is listed below :


					
	    Classes
		Class BorderLayout			Class MenuBar
		Class Button				Class MenuComponent
		Class Canvas				Class MenuItem
		Class CardLayout			Class Panel
		Class CheckBox				Class Point
		Class CheckBoxGroup			Class Polygon
		Class CheckBoxMenuItem		        Class Rectangle
		Class Choice				Class ScrollBar
		Class Color			        Class TextArea
		Class Component				Class TextComponent
		Class Container				Class TextField
		Class Dialog				Class Toolkit
		Class Dimension				Class Window
		Class Event
		Class FileDialog			Interfaces
		Class FlowLayout			Interface LayoutManager
		Class Font			        Interface MenuContainer
		Class FontMatrices			
		Class Frame			        Errors
		Class Graphics				Class AWTException
		Class GridBagConstraints                Class AWTError
		Class GridBagLayout
		Class GridLayout
		Class Image
		Class Insets
		Class Label
		Class List
		Class MediaTracker
		Class Menu	
		
		

Class BorderLayout

A BorderLayout lays out a container to contain number of GUI element like buttons, labels, Grids texts etc. Following is the varopus methods in this class :

	public  class  java.awt.BorderLayout extends  java.lang.Object   
		implements java.awt.LayoutManager  
		{
			// 	Constructors
			public BorderLayout();

			//	Default constructor, constructs a new border layout.	 
			public BorderLayout(int  hgap, int  vgap);
			
			/*	Creates a new border layout with the specified horizontal and vertical gaps. The horizontal and vertical gaps specify the space between the components.
			*/

			// 	Methods
			public void  addLayoutComponent(String  name, Component  comp);
			public void layoutContainer(Container  target);	 
			public Dimension minimumLayoutSize(Container  target);	 
			public Dimension preferredLayoutSize(Container  target);	 
			public void removeLayoutComponent(Component  comp);	 
			public String toString();	 
		}
Methods in this class are described in Table 4.1.

Table 4.1

Method

Description

addLayoutComponent(String         name,Component  comp)

Adds the specified component to this border layout using the indicated tag.Most applications do not call this method directly. This method is called when a component is added to a container using the two-argument add method.

layoutContainer(Container                        target)     

Lays out the container argument using this border layout. This method reshapes the components in the specified container in order to satisfy the constraints of this BorderLayout object. Most applications do not call this method directly. This method is called when a container calls its layout method.

minimumLayoutSize(Container                     target)

Determines the minimum size of the target container using this layout manager.This method is called when a container calls its minimumSize method.

Most applications do not call this method directly.

Returns : the minimum dimensions needed to lay out the subcomponents of the specified container.

preferredLayoutSize(Container                     target)

Determines the preferred size of the target container using this layout manager.  This  method is called when a container calls its preferredSize method.

Most applications do not call this method directly.

Returns: the preferred dimensions to lay out the subcomponents of the specified container.

removeLayoutComponent                 (Component  comp)

Removes the specified component from this border layout. This method is called when a container calls its remove or removeAll methods. Most applications do not call this method directly.

toString()

Returns : a string representation of this border layout.

Class Button

This class creates a labeled button.

public  class  java.awt.Button extends  java.awt.Component  
	{
// 	Constructors
		public Button();	
		//	Creates a button with no label. 
		public Button(String  label);	
		//	Creates a button with the indicated label. 

		// 	Methods
		public void addNotify();	 
		public String getLabel();	 
		protected String paramString();	 
		public void setLabel(String  label);	 
	}

Table 4.2

Method

Description

addNotify()

This method calls the createButton method of the button's toolkit in order to create a ButtonPeer for this button. This peer allows the application to change the look of a button without changing its functionality. Most applications do not call this method directly.

getLabel()

Returns: the label of this button, or null if this button has no label.

paramString()

Returns the parameter string representing the state of this button. This string is useful for debugging.

Returns: the parameter string of this button.

setLabel(String  label)

Changes this button's label to be the String argument.

Class Canvas

A Canvas component represents a blank rectangular area of the screen onto which the application can draw or from which the application can trap input events from the user. An application must subclass the Canvas class in order to get useful functionality such as creating a custom component. The paint method must be overridden in order to perform custom graphics on the canvas. The AWT sends the canvas all mouse, keyboard, and focus events that occur over it. The gotFocus, lostFocus, keyDown, keyUp, mouseEnter, mouseExit, mouseMove, mouseDrag, mouseDown, and mouseUp methods may be overridden in order to catch user events.

public  class  java.awt.Canvas extends  java.awt.Component  
	{
		// 	Constructors
		public Canvas();	 

			
		// 	Methods
		public void addNotify();	 
		public void paint(Graphics  g); 
	}

Table 4.3

Method

Description

addNotify()

This method calls the createCanvas method of the canvas's toolkit in order to create a CanvasPeer for this canvas. This peer allows the application to change the look of a canvas without changing its functionality.  Most applications do not call this method directly.

paint(Graphics  g)

This method is called to repaint this canvas. Most applications should override this method in order to perform some useful operation.  The paint method provided by Canvas redraws this canvas's rectangle in the background color.

Class CardLayout

A layout manager for a container that contains several "cards". Only one card is visible at a time, allowing the application to flip through the cards. This class provides us to manage such cards.

public  class  java.awt.CardLayout extends  java.lang.Object  
	implements java.awt.LayoutManager  
	{
		// 	Constructors
		public CardLayout();
		//	Default constructor, creates a new card layout.	 
		public CardLayout(int  hgap, int  vgap);	
		/*	Creates a new card layout with the specified horizontal and vertical gaps. The horizontal gaps are placed and the left and right edge. The vertical gaps are placed at the top and bottom edge. 
		*/
		// 	Methods
		public void addLayoutComponent(String  name, Component  comp);  
		public void first(Container  target);	 
		public void last(Container  target);	 
		public void layoutContainer(Container  target);	 
		public Dimension minimumLayoutSize(Container  target);	 
		public void next(Container  target);	 
		public Dimension preferredLayoutSize(Container  target);	 
		public void previous(Container  target);	 
		public void removeLayoutComponent(Component  comp);	 
		public void show(Container  target, String  name);	 
		public String toString();	 
	}

Table 4.4 

Method

Description

addLayoutComponent(String  name,               Component  comp)

Adds the specified component to the card layout using the indicated name tag. The show method can be used to display the component with the specified tag.

first(Container  target)

Flips to the first card of the container.

last(Container  target)

Flips to the last card of the container.

layoutContainer(Container                 target)

Lays out the container argument using this card layout.  Each component in the target container is reshaped to be the size of the container minus space for surrounding insets, horizontal gaps, and vertical gaps.  Most applications do not call this method directly. This method is called when a container calls its layout method.

minimumLayoutSize           (Container  target)

Determines the minimum size of the container argument using this card layout.  The minimum width of a card layout is the largest minimum width of the cards in the container, plus twice the horizontal gap, plus the left and right insets. The minimum height of a card layout is the largest minimum height of the cards in the container, plus twice the vertical gap, plus the top and bottom insets.  Most applications do not call this method directly. This method is called when a container calls its layout method.

Returns : the minimum dimensions needed to lay out the subcomponents of the specified container.

next(Container  target)

Flips to the next card of the specified container. If the currently visible card is the last one, this method flips to the first card in the layout.

preferredLayoutSize           (Container  target)

Determines the preferred size of the container argument using this card layout.  The preferred width of a card layout is the largest preferred width of the cards in the container, plus twice the horizontal gap, plus the left and right insets. The preferred height of a card layout is the largest preferred height of the cards in the container, plus twice the vertical gap, plus the top and bottom insets.   Most applications do not call this method directly. This method is called when a container calls its preferredSize method.

Returns: the preferred dimensions to lay out the subcomponents of the specified container.

previous(Container                      target)

Flips to the previous card of the specified container. If the currently visible card is the first one, this method flips to the last card in the layout.

removeLayoutComponent          (Component  comp)

Removes the specified component from the layout. This method is called when a container calls its remove or removeAll methods. Most applications do not call this method directly.

show(Container  target,          String  name)

Flips to the component that was added to this layout with the specified name tag. If no such component exists, then nothing happens.

toString()

Returns: a String representation of this card layout. 

Class CheckBox

A check box is a graphical component that has an "on" (true) and "off" (false) state. Clicking on the check box changes its state from "on" to "off" or from "off" to "on". When the check box is clicked, AWT sends an action event to the check box. This event's target is the check box, and its object is a Boolean giving the new state of the check box. An application should override the action method of the check box or of one of its containing windows in order to cause some action to occur. Optionally, several checkboxes can be grouped together into a CheckboxGroup. At most one button in a group can be in the "on" state at any given time. Pushing a check box to turn it "on" forces any other check box in the group that is "on" to become "off".

public  class  java.awt.Checkbox extends  java.awt.Component  
	{
		// 	Constructors
		public Checkbox();	 
		//	Creates a check box with no label. The check box is set to "off" and is not part of any check box group. 
		public Checkbox(String  label);
		//	Creates a check box with the specified label. The check box is set to "off" and is not part of any check box group. 	 
		public Checkbox(String  label, CheckboxGroup  group, boolean  state);
		//	Creates a check box with the specified label, in the specified check box group, and set to the specified state.

		// 	Methods
		public void addNotify(); 
		public CheckboxGroup getCheckboxGroup(); 
		public String getLabel(); 
		public boolean getState(); 
		protected String paramString(); 
		public void setCheckboxGroup(CheckboxGroup  g);	 
		public void setLabel(String  label);	 
		public void setState(boolean  state);	 
	}

Table 4.5

Method

Description

addNotify()

This method calls the createCheckbox method of the check box's toolkit in order to create a CheckboxPeer for this button. This peer allows the application to change the look of a check box without changing its functionality. Most applications do not call this method directly

getCheckboxGroup()

Determines this check box's group.

Returns:  thischeck box's group, or null if it is not part of a check box group.

getLabel()

Returns: the label of this check box, or null if this check box has no label.

getState()

Determines if this check box is "on" or "off.".

 Returns: the state of this check box. The value true indicates "on", false indicates "off".

paramString()

Returns the parameter string representing the state of this check box. This string is useful for debugging.

Returns: the parameter string of this check box.

setCheckboxGroup                   (CheckboxGroup  g)

Sets the group of this check box to be the specified check box group. If this check box is already in a different check box group, it is first taken out of that group.

setLabel(String  label)

Sets this check box's label to be the string argument.

setState(boolean  state)

Sets this check box to the specifed boolean state: true indicates "on"; false indicates "off".

Class CheckboxGroup

This class is used to group together a set of Checkbox buttons. Exactly one check box button in a CheckboxGroup can be in the "on" state at any given time. Pushing any button turns it "on" and forces any other button that is "on" to become "off". When a check box in a check box group is clicked, AWT sends an action event to that check box. This event's target is the check box, and its object is a value equal to Boolean.TRUE . No action event is sent to the check box (if any) that is turned off. An application should override the action method of the check box or of one of its parent containers in order to cause some action to occur.

public  class  java.awt.CheckboxGroup extends  java.lang.Object  
	{
		// 	Constructors
		public CheckboxGroup();	
		//	Default constructor,  creates a new CheckboxGroup.

		// 	Methods
		public Checkbox getCurrent();	 
		public void setCurrent(Checkbox  box); 
		public String toString();	 
	}

Table 4.6

Method

Description

getCurrent()

Returns: the check box in this check box group that is currently "on", or null if all are "off".

setCurrent(Checkbox  box)

If the indicated check box argument belongs to this check box group, this method sets that check box to be "on", and all other checkboxes in this group to be "off".  If the check box argument is null or belongs to a different check box group, then this method does nothing.

toString()

Returns: a string representation of this check box group. 

Class CheckboxMenuItem

This class represents a check box that can be included in a menu. Clicking on the check box in the menu changes its state from "on" to "off" or from "off" to "on". When a check box menu item is clicked, the AWT sends an action event to the check box menu item's containing frame. The event's target is the check box menu item, and its object is the string label of the check box.

public  class  java.awt.CheckboxMenuItem extends  java.awt.MenuItem
	{
		// 	Constructors
		public CheckboxMenuItem(String  label);
		//	Creates a check box with the specified label. The check box is initially set to "off".
		// 	Methods
		public void addNotify();	
		public boolean getState(); 
		public String paramString();	 
		public void setState(boolean t); 
	}

Table 4.7

Method

Description

addNotify()

This method calls the createCheckboxMenuItem method of the check box's toolkit in order to create a CheckboxMenuItemPeer for this button. This peer allows the application to change the look of a check box menu item without changing its functionality. Most applications do not call this method directly.

getState()

Determines whether this check box menu item is "on" or "off.".

Returns: the state of this check box menu item: true indicates "on", false indicates "off".

paramString()

Returns the parameter string representing the state of this check box menu item. This string is useful for debugging.

Returns: the parameter string of this check box menu item. 

setState(boolean  t)

Sets this check box menu item to the specifed boolean state: true indicates "on"; false indicates "off".

Class Choice

The Choice class presents a pop-up menu of choices. The current choice is displayed as the title of the menu. After any choice is made, AWT sends an action event to the choice menu. The event's target is the choice menu, and its object is the string label of the currently selected item. An application should override the action method of the choice menu or of one of its parent containers in order to cause some action to occur.

public  class  java.awt.Choice extends  java.awt.Component  
	{
		// 	Constructors
		public Choice();	 
		/*	Creates a new choice menu. The menu initially has no items in it. By default, the first item added to the choice menu becomes the selected item, until a different selection is made by the user or by calling one of the select methods.
		*/
		// 	Methods
		public void addItem(String  item);	 
		public void addNotify(); 
		public int countItems();	 
		public String getItem(int  index);	 
		public int getSelectedIndex();	 
		public String getSelectedItem(); 
		protected String paramString();	 
		public void select(int  pos);	 
		public void select(String  str); 
	}

Table 4.8

Method

Description

addItem(String  item)

Adds an item to this choice menu.

Throws : NullPointerException, if the item's value is equal to null

addNotify()

This method calls the createChoice method of this object's toolkit in order to create a ChoicePeer for this button. This peer allows the application to change the look of a choice mneu without changing its functionality. Most applications do not call this method directly.

countItems()

Returns: the number of menu items in this choice menu.

getItem(int  index)

Returns: the string at the specified index in this choice menu.

getSelectedIndex()

Returns: the index of the currently selected item in this choice menu.

getSelectedItem()

Returns: a string representation of the currently selected item in this choice menu.

paramString()

Returns the parameter string representing the state of this choice menu. This string is useful for debugging. Returns: the parameter string of this choice menu.

select(int  pos)

Sets the selected item in this choice menu to be the item at the specified position.

Throws : IllegalArgumentException,  if the choice item position is invalid.

select(String  str)

Sets the selected item in this choice menu to be the choice whose name is equal to the specified string. If more than one choice is equal to the specified string, the one with the smallest index whose name matches is selected.

Class Color

This class encapsulate colors using the RGB format. In this format, the red, blue, and green components of a color a each represented by an integer in the range 0-255. The value 0 indicates no contribution from this primary color. The value 255 indicates the maximum intensity of this color component.

public  final  class  java.awt.Color extends  java.lang.Object
{
		// 	Member elements
		public final static Color black;	
		public final static Color blue;	 
		public final static Color cyan; 
		public final static Color darkGray;	 
		public final static Color gray;	 
		public final static Color green;	 
		public final static Color lightGray;	 
		public final static Color magenta;	 
		public final static Color orange;	 
		public final static Color pink;	 
		public final static Color red;	 
		public final static Color white;	 
		public final static Color yellow;	 

		// 	Constructors
		public Color(float  r, float  g, float  b);	
		/*	Creates a color with the specified red, green, and blue values, where each of the values is in the range 0.0-1.0. The value 0.0 indicates no contribution from the primary color component. The value 1.0 indicates the maximum intensity of the primary color component. The actual color used in rendering depends on finding the best match given the color space available for a given output device.
		*/
		public Color(int  rgb);	 
		/*	Creates a color with the the specified RGB value, where the red component is in bits 16-23 of the argument, the green component is in bits 8-15, of the argument, and the blue component is in bits 0-7. The value 0 indicates no contribution from the primary color component.
		*/
		public Color(int  r, int  g, int  b);
		/*	Creates a color with the specified red, green, and blue components. The three arguments must each be in the range 0-255. 	  
		*/
		// 	Methods
		public Color brighter();	 
		public Color darker();	 
		public boolean equals(Object  obj); 
		public int getBlue();	 
		public static Color getColor(String  nm);	 
		public static Color getColor(String  nm, Color  v);	 
		public static Color getColor(String  nm, int  v); 
		public int getGreen();	 
		public static Color getHSBColor(float  h, float  s, float  b);
		public int getRed(); 
		public int getRGB();	 
		public int hashCode();	 
		public static int HSBtoRGB(float  hue, float  saturation, float brightness);	
													
		public static float[] RGBtoHSB(int  r, int  g, int  b, float  hsbvals[]);
														   
		public String toString();	 
	}

Table 4.9

Method

Description

brighter()

Returns: a brighter version of this color.

darker()

Returns: a darker version of this color.

equals(Object  obj)

The result is true if and only if the argument is not null and is a Color object that has the same red, green, and blue value as this object.

Returns: true if the objects are the same; false otherwise. 

getBlue()

Returns the blue component of this color. The result is in the range 0 to 255.

getColor(String  nm)

Finds a color in the system properties.The first argument is treated as the name of a system property to be obtained as if by the method System.getProperty . The string value of this property is then interpreted as an integer value (see Integer.getInteger for information on how the string value is interpreted as an integer). This integer is then converted to a color by using the Color constructor that takes one integer argument If the specified property is not found, or could not be parsed as an integer, then null is returned.

getColor(String  nm,Color  v)

Finds a color in the system properties.   The first argument is treated as the name of a system property to be obtained as if by the method System.getProperty.The string value of this property is then interpreted as an integer value. This integer is then converted to a color by using the color constructor that takes one integer argument.If the specified property is not found, or could not be parsed as an integer, then the color specified by the second argument is returned instead.

getColor(String  nm,                  int  v)

Finds a color in the system properties. The first argument is treated as the name of a system property to be obtained.  If the specified property is not found, or could not be parsed as an integer, then the integer value v is used instead.   This integer is then converted to a color by using the Color constructor that takes one integer argument.  

getGreen()

Returns the green component of this color. The result is in the range 0 to 255.

getHSBColor(float  h, float  s, float  b)

Determines the hue, saturation, and brightness of a color. Each of the three components should each be a floating point number in the range

getRed()

Returns the red component of this color. The result is in the range 0 to 255.

getRGB()

Calculates a single integer representing the red, green, and blue components of this color. The red, green, and blue components of the color are each scaled to be a value between 0 (absence of the color) and 255 (complete saturation). The integer returned is the number between 0 and 0xFFFFFF such that bits 16-23 are the red value, bits 8-15 are the green value, and bits 0-7 are the blue value.

hashCode()

Returns: a hash code value for this object.

HSBtoRGB(....)

Converts a color specified by hue, saturation, and brightness, to a corresponding RGB value. Returns: the RGB value of the color with the indicated hue, saturation, and brightness.

RGBtoHSB(....)

Converts a color specified by its red, green, and blue components to hue, saturation, and brightness.  If the hsbvals argument is null, then a new array is allocated to return the result. Otherwise, hsbvals is returned as the result, with the values put into that array.

Returns: an array of three elements containing the hugh, saturation, and brightness (in that order), of the color with the indicated red,geen,and blue components

toString()

Returns: a string representation of this color.

Class Component

The Component class is the abstract superclass of many of the Abstract Window Toolkit classes. With the aid of this class we can position, resize, and can be painted something on the screen, and can receive input events from mouse keyboar etc. This class enriched of number of methods which are listed below :

public  abstract  class  java.awt.Component	extends  java.lang.Object  
	implements java.awt.image.ImageObserver  
	{
		// 	Methods
		public boolean  action(Event  evt, Object  what);	 
		public void addNotify();	 
		public Rectangle bounds();	 
		public int checkImage(Image  image, ImageObserver  observer);
		public int checkImage(Image  image, int  width, int  height, ImageObserver  observer);
		public Image createImage(ImageProducer  producer);	 
		public Image createImage(int  width, int  height);	 
		public void deliverEvent(Event  evt);	
		public void disable();	
		public void enable();	 
		public void enable(boolean  cond);	 
		public Color getBackground();	 
		public ColorModel getColorModel();	 
		public Font getFont(); 
		public FontMetrics getFontMetrics(Font  font);	 
		public Color getForeground();	  
		public Graphics getGraphics(); 
		public Container getParent();	 
		public ComponentPeer getPeer();	 
		public Toolkit getToolkit();	 
		public boolean gotFocus(Event  evt, Object  what);	 
		public boolean handleEvent(Event  evt);	 
		public void hide();	 
		public boolean imageUpdate(Image  img, int  flags, int  x, int  y,int  w, int  h);
		public boolean inside(int  x, int  y);	 
		public void invalidate();	 
		public boolean isEnabled();	 
		public boolean isShowing();	 
		public boolean isValid();	 
		public boolean isVisible(); 
		public boolean keyDown(Event  evt, int  key);	 
		public boolean keyUp(Event  evt, int  key); 
		public void layout();	 
		public void list();	 
		public void list(PrintStream  out);	 
		public void list(PrintStream  out, int  indent);	 
		public Component locate(int  x, int  y);	 
		public Point location();	 
		public boolean lostFocus(Event  evt, Object  what);	 
		public Dimension minimumSize(); 
		public boolean mouseDown(Event  evt, int  x, int  y);	 
		public boolean mouseDrag(Event  evt, int  x, int  y);	 
		public boolean mouseEnter(Event  evt, int  x, int  y); 
		public boolean mouseExit(Event  evt, int  x, int  y);	 
		public boolean mouseMove(Event  evt, int  x, int  y);	 
		public boolean mouseUp(Event  evt, int  x, int  y);	 
		public void move(int  x, int  y); 
		public void nextFocus();	 
		public void paint(Graphics  g); 
		public void paintAll(Graphics  g);	 
		protected String paramString();	 
		public boolean postEvent(Event  evt); 
		public Dimension preferredSize();	 
		public boolean  prepareImage(Image  image,  ImageObserver  observer);
		public  prepareImage(Image  image,  int  width, int height,ImageObserver observer);	     
		public void print(Graphics  g);	 
		public void printAll(Graphics  g);	 
		public void removeNotify();	 
		public void repaint();	 
		public void repaint(int  x, int  y, int  width, int height);	 
		public void repaint(long  tm);	 
		public void repaint(long  tm, int  x, int  y,int  width, int  height);
		public void requestFocus(); 
		public void reshape(int  x, int  y, int  width, int height);	 
		public void resize(Dimension  d); 
		public void resize(int  width, int  height); 
		public void setBackground(Color  c); 
		public void setFont(Font  f);	 
		public void setForeground(Color  c);	  
		public void show(); 
		public void show(boolean  cond);	 
		public Dimension size();	 
		public String toString();	 
		public void update(Graphics  g); 
		public void validate();	 
	}

 

 Table 4.10

Method

Description

action(Event  evt, Object  what)

This method is called when an action occurs inside this component. This method is usually called by handleEvent in which case the what argument contains the arg field of the event argument. The specific value and type of the what argument depends on the component that originally triggered the action. The method returns true to indicate that it has successfully handled the action or false if the event that triggered the action should be passed up to the component's parent. Most applications should return either true or the value of super.handleEvent(evt). The action method of Component simply returns false.

Returns :  true if the event has been handled and no further action is necessary; false if the event is to be given to the component's parent.

addNotify()

This method notifies the Component to create a peer. This peer allows the application to change the look of a component without changing its functionality. The addNotify method of Component sets a flag indicating that the component needs to be laid out again because its size has possibly changed.Most applications do not call this method directly.

bounds()

Returns: the containing rectangle of this component..

checkImage(Image  image,               ImageObserver  observer)

Returns the status of the construction of a screen representation of the specified image. This method does not cause the image to begin loading. An application must use the prepareImage method to force the loading of an image. The checkImage method of Component calls its peer's checkImage method to calculate the flags. If this component does not yet have a peer, the component's toolkit's checkImage method is called instead. Information on the flags returned by this method can be found in. Returns: the bitwise inclusive OR of ImageObserver flags indicating what information about the image is currently available.

checkImage(Image  image, int            width, int  height,           ImageObserver  observer)                              

Returns the status of the construction of a scaled screen representation of the specified image. This method does not cause the image to begin loading. An application must use the prepareImage method to force the loading of an image. The checkImage method of Component calls its peer's checkImage method to calculate the flags. If this component does not yet have a peer, the component's toolkit's checkImage method is called instead. Information on the flags returned by this method can be found in.

Returns: the bitwise inclusive OR of the ImageObserver flags for the data that is currently available.

createImage(ImageProducer                             producer)

Creates an image from the specified image producer.

 

Returns: the image produced.

createImage(int  width, int                             height)

Returns: an off-screen drawable image, which can be used for double buffering

deliverEvent(Event  evt)

Delivers an event to this component or one of its subcomponents. The deliverEvent method of Component calls the component's postEvent method on the event

disable()

Makes this component insensitive to user input.

enable()

Makes this component sensitive to user input. This is the default.

enable()

If the boolean argument is true, enables this component. If false, disables it.

getBackground()

Determines the background color of this component. If this component has not specified a background color using the setBackground method, the background color of its parent component is returned.

getColorModel()

Detetermins the color model of this component. The ColorModel is an abstract class that encapsulates how to translate between pixel values of an image and its red, green, blue, and alpha (transparency) components. The getColorModel method of Component calls its peer's getColorModel method to determine the component's color model. If this component does not yet have a peer, the component's toolkit's getColorModel method is called instead.

Returns: the color model of this component.

getFont()

Determines the font of this component. If this component has not yet specified a font using the setFont method, the font of its parent component is returned.

Returns: the font of this component.

getFontMetrics(Font  font)

Determines the font metrics for the specified font when rendered by a platform-dependent toolkit. The getFontMetrics method checks to see if this component has a peer . If so, the peer's getFontMetrics method is called. Otherwise, the component's toolkit's get-Font-Metrics method is called. Returns: the font metrics for the specified font.

getForeground()

Determines the foreground color of this component. If this component has not specified a background color using the setForeground method,the background color of its parent component is returned.Returns: the foreground color of this component.

getGraphics()

Returns: the graphics context of this component; this method returns null if the component does not currently have a peer.

getParent()

Returns: the parent of this component.

getPeer()

Returns:  the peer of this component.

getToolkit()

The toolkit is used to create this component's peer when its its addNotify method is called. A Component's toolkit is determined by its containing Frame .

 

Returns: the toolkit of this component.

gotFocus(Event  evt, Object  what)

This method is called when the this component receives the input focus. This method is usually called by handleEvent in which case the what argument contains the arg field of the event argument. The method returns true to indicate that it has successfully handled the action; or false if the event that triggered the action should be passed up to the component's parent. Most applications should return either true or the value of super.handleEvent(evt). The getFocus method of Component simply returns false. The what argument is currently always null.

handleEvent(Event  evt)

This method is called when any event occurs inside this component. The method returns true to indicate that it has successfully handled the action; or false if the event that triggered the action should be passed up to the component's parent. The handleEvent method of Component determines the type of event, and calls one of the following methods, if appropriate:

	action
		   gotFocus    lostFocus
		   keyDown     keyUp
		   mouseEnter  mouseExit
		   mouseMove   mouseDrag
		   mouseDown    mouseUp		   
  
and returns whatever value that method returns. If none of those methods is appropriate, then handleEvent returns false. All the above methods are called with the event as their first argument. The action method is called with the arg field of the event as its second argument. The keyUp and keyDown are passed the key field of the event as its second argument. The six mouse methods are passed the x and y fields of the event as their second and third argument, respectively.

hide()

Hides this component. The component continues to exist and be in its containing object, but it is not visible and does not have any space allocated for it.

imageUpdate(Image  img, int  flags, int  x,int  y, int  w,                       int  h)

This imageUpdate method of an ImageObserver (such as Component) is called when more information about an image which had been previously requested using an asynchronous interface (such as drawImage) becomes available.  The imageUpdate method of Component incrementally draws an image on the component as more of the bits of the image are available.   If the system property "awt.image.incrementalDraw" is missing or has the value "true", the image is incrementally drawn, If the system property has any other value, then the image is not drawn until it has been completely loaded.  Also, if incremental drawing is in effect, the value of the system property "awt.image.redrawrate" is interpreted as an integer to give the maximum redraw rate, in milliseconds. If the system property is missing or cannot be interpreted as an integer, the redraw rate is once every 100ms.  The interpretation of the x, y, width, and height arguments depends on the infoflags argument.

Returns: true if the flags have indicated that the image is completely loaded; false otherwise.

inside(int  x, int  y)                                   

Determines if the specified location is inside this component. The inside method of Component returns true if the location is inside the bounding box of the component. Returns: true if the specified location lies within this component; false otherwise.

invalidate()

Invalidates this component. This component is marked as having changed. The next call to the validate method on this component or its parent(s) causes the component to be laid out again.

isEnabled()

Indicates whether this component is enabled to receive events. By default, components are initially enabled. A component is disabled by calling its disable method . A component is enabled by calling its enable method. Returns: true if this component is enabled; false otherwise.

isShowing()

Indicates whether this component is visible. A component is showing if it is visible and is inside a container this is both visible and showing. A component is hidden by calling its hide method. A component is made visible by calling its show method.

Returns: true if this component is showing; false otherwise.

isValid()

Indicates whether this component is valid. A component is valid if it has a peer and it and its subcomponents have been properly laid out. Returns: true if this component is valid; false otherwise.

isVisible()

Indicates whether this component is visible. Except for top-level components such as a frame, components are visible unless they have been specifically been made invisible by a call to the hide method.

Returns: true if this component is showing; false otherwise.

keyDown(Event  evt, int  key)

This method is called when a key is pressed and this component has the focus. This method is usually called by handleEvent, in which case the key argument contains the key field of the event argument. This method returns true to indicate that it has successfully handled the action; or false if the event that triggered the action should be passed up to the component's parent. Most applications should return either true or the value of super.handleEvent(evt). The keyDown method of Component simply returns false.

keyUp(Event  evt, int  key)

This method is called when a key is released and this component has the focus. This method is usually called by handleEvent in which case the key argument contains the key field of the event argument. This method returns true to indicate that it has successfully handled the action; or false if the event that triggered the action should be passed up to this component's parent. Most applications should return either true or the value of super.handleEvent(evt). The keyUp method of Component simply returns false.

layout()

This method is called to lay out the subcomponents of this component so that they fit inside the borders of this component.  This method is called when this component is validated by a call to the validate method .Most applications should not call this method directly. The layout method of Component does nothing.

list()

Prints a listing of this component to System.out.

list(PrintStream  out)

Prints a listing of this component to the specified output stream.

list(PrintStream  out, int                              indent)

Prints a listing of this component to the specified output stream. The listing starts at the specified indentation. The list method of Component calls the println method on the component after indenting by the specified amount

locate(int  x, int  y)

Determines if this component or one of its subcomponents contains the (x, y) coordinate, and if so returns the containing component. This method only looks one level deep. If the point is (x, y)inside a subcomponent that itself has subcomponents, it does not go looking down the subcomponent tree. The locate method of Component simply returns the component itself if the (x, y) coordinate is inside its bounding box, and null otherwise.

Returns: the component or subcomponent that contains the (x, y) coordinate ; null if the coordinate is outside this component.

location()

Returns: the location of this component in its parent's coordinate space.

lostFocus(Event  evt, Object; what)

This method is called when this component loses the input focus. This method is usually called by handleEvent, in which case the what argument contains the arg field of the event argument. This method returns true to indicate that it has successfully handled the action; or false if the event that triggered the action should be passed up to this component's parent. Most applications should return either true or the value of super.handleEvent(evt). The getFocus method of Component simply returns false. The what argument is currently always null.

Returns: true if the event has been handled and no further action is necessary; false if the event is to be given to the component's parent.

minimumSize()

Determines the minimum size of thiscomponent. The minimumSize method of Component checks to see if the component has a peer . If so, the minimumSize request is passed to the peer . Otherwise, the minimum size is the width and height specified by the most recent reshape or resize method call.

Returns: the minimum size of this component.

mouseDown(Event  evt, int  x,int  y)

This method is called when the mouse button is pushed inside this component. This method is usually called by handleEvent in which case the x and y arguments contains the x and y field of the event argument.The (x, y) coordinate is relative to the top-left corner of this component. This method returns true to indicate that it has successfully handled the action; or false if the event that triggered the action should be passed up to this component's parent. Most applications should return either true or the value of super.handleEvent(evt). The mouseDown method of Component simply returns false.

Returns: true if the event has been handled and no further action is necessary; false if the event is to be given to the component's parent.

mouseDrag(Event  evt, int  x,int  y)

This method is called when the mouse button is moved inside this component with the button pushed. This method is usually called by handleEvent , in which case the x and y arguments contains the x and y field of the event argument. The (x, y) coordinate is relative to the top- left corner of this component. Mouse drag events continue to get sent to this component even when the mouse has left the bounds of the component. The drag events continue until a mouse up event occurs. This method returns true to indicate that it has successfully handled the action; or false if the event that triggered the action should be passed up to this component's parent. Most applications should return either true or the value of super.handleEvent(evt). The mouseDrag method of Component simply returns false.

Returns: true if the event has been handled and no further action is necessary; false if the event is to be given to the component's parent.

mouseEnter(Event  evt, int  x, int  y)

This method is called when the mouse button is moved inside this component with the button pushed. This method is usually called by handleEvent , in which case the x and y arguments contains the x and y field of the event argument. The (x, y) coordinate is relative to the top- left corner of this component. Mouse drag events continue to get sent to this component even when the mouse has left the bounds of the component. The drag events continue until a mouse up event occurs. This method returns true to indicate that it has successfully handled the action; or false if the event that triggered the action should be passed up to this component's parent. Most applications should return either true or the value of super.handleEvent(evt). The mouseDrag method of Component simply returns false.

Returns: true if the event has been handled and no further action is necessary; false if the event is to be given to the component's parent.

mouseExit(Event  evt, int  x,int  y)

This method is called when the mouse exits this component. This method is usually called by handleEvent, in which case the x and y arguments contains the x and y field of the event argument. The (x, y) coordinate is relative to the top-left corner of this component. Most applications should return either true or the value of super.handleEvent(evt). This method returns true to indicate that it has successfully handled the action; or false if the event that triggered the action should be passed up to this component's parent. Most applications should return either true or the value of super.handleEvent(evt). The mouseEixt method of Component simply returns false.

Returns: true if the event has been handled and no further action is necessary; false if the event is to be given to the component's parent.

mouseMove(Event  evt, int  x,int  y)

This method is called when the mouse is moved inside this component with the mouse button not pushed. This method is usually called by handleEvent in which case the x and y arguments contains the x and y field of the event argument. The (x, y) coordinate is relative to the top-left corner of this component. This method returns true to indicate that it has successfully handled the action; or false if the event that triggered the action should be passed up to this component's parent. Most applications should return either true or the value of super.handleEvent(evt).The mouseMove method of Component simply returns false.

Returns:true if the event has been handled and no further action is necessary; false if the event is to be given to the component's parent.

mouseUp(Event  evt, int  x,int  y)

This method is called when the mouse button is released inside this component. This method is usually called by handleEvent , in which case the x and y arguments contains the x and y field of the event argument. The (x, y) coordinate is relative to the top-left corner of the component. This method returns true to indicate that it has successfully handled the action; or false if the event that triggered the action should be passed up to this component's parent. Most applications should return either true or the value of super.handleEvent(evt). The mouseUp method of Component simply returns false.

Returns: true if the event has been handled and no further action is necessary; false if the event is to be given to the component's parent.

move(int  x, int  y)

Moves this component to the coordinate (x, y) coordinate is relative to the top-left corner of the parent component. Components that are in a container with a layout manager should not call this method explicitly.

nextFocus()

Moves the input focus to the next component, as determined by the component's peer

paint(Graphics  g)

Paints this component. Most application components, including applets, override this method. The paint method of Component calls the repaint method of this component's peer. The ( 0, 0) coordinate of the graphics context is the top-left corner of this components. The clipping region of the graphics context is the bounding rectangle of this component. The paint method of Component calls the repaint method of this component's peer.

paintAll(Graphics  g)

Paints this component and all of its subcomponents. The ( 0, 0 ) coordinate of the graphics context is the top-left corner of this component. The clipping region of the graphics context is the bounding rectangle of this component

paramString()

Returns the parameter string representing the state of this component. This string is useful for debugging..

postEvent(Event  evt)

Posts an event to this component by calling its handleEvent method. If handleEvent returns false, the event is posted to this component's parent. If this component and all of its parents return false, the event is passed to this component's peer object's handleEvent method.

Returns: true if this component, one of its parents, or this component's peer handled the event; false otherwise.

preferredSize()

Determines the preferred size of the component. The preferredSize method of Component checks to see if this component has a peer. If so, the preferredSize request is passed to the peer . Otherwise, the preferred size is the width and height specified by the most recent reshape or resize method call. Returns: the preferred size of this component.

prepareImage(Image  image,  ImageObserver  observer)

Prepares an image for rendering on this component.  The image data is downloaded asynchronously in another thread and the appropriate screen representation of the image is generated.

Returns: true if the image has already been fully prepared; false otherwise.

prepareImage(Image  image,  int            width, int height,          ImageObserver observer)

Prepares an image for rendering on this component at the specified width and height.  The image data is downloaded asynchronously in another thread and an appropriately scaled screen representation of the image is generated.

Returns: true if the image has already been fully prepared; false otherwise.

print(Graphics  g)

 The print method of Component calls the paint method. The( 0, 0 ) coordinate of the graphics context is the top-left corner of this component. The clipping region of the graphics context is the bounding rectangle of this component

printAll(Graphics  g)

Paints this component and all of its subcomponents.  The ( 0, 0 ) coordinate of the graphics context is the top-left corner of this component. The clipping region of the graphics context is the bounding rectangle of this component.

removeNotify()

Notifies this component and all its subcomponents to destroy their peers. Applications should not call this method directly. It is called when a component is removed from its container.   The removeNotify method of Component removes the components peer and has the peer clean up after itself by calling its dispose method.

repaint()

Repaints this component. This method causes a call to this component's update method as soon as possible.

repaint(int  x, int  y, int   width, int   height)

Repaints the specified rectangle of this component. This method causes a call to this component's update method as soon as possible.

repaint(long  tm)

Repaints theis component within tm milliseconds.                

 This method causes a call to this component's update method.

repaint(long  tm, int  x, int        y,int  width, int  height)

Repaints the specified rectangle of this component within tm milliseconds.  This method causes a call to this component's update method.

requestFocus()

Requests that this component get the input focus. This component's gotFocus method is called when this method is successful. The requestFocus method of Component calls the request-Focus method of the component's peer.

reshape(int  x, int  y, int  width, int height)

Reshapes this component to the specified bounding box in its parent's coordinate space. Components that are in a container with a layout manager should not call this method explicitly.

resize(Dimension  d)

Resizes this component to the width and height specified by the dimension argument. Components that are in a container with a layout manager should not call this method explicitly.

resize(int  width, int  height)

Resizes this component to the specified width and height. Components that are in a container with a layout manager should not call this method explicitly.

setBackground(Color  c)

Sets the background color of this component. The setBackground method of Component calls the setBackground method as soon as possible of the component's peer.

setFont(Font  f)

Sets the font of this component. The setFont method of Component calls the setFont method as soon as possible of the component's peer.

setForeground(Color  c)

Sets the foreground color of this component.  The setForeground method of Component calls the setForeground method of the component's peer.

show()

Shows this component; if this component had been made invisible by a call to the hide method,makes this component visible again.

show(boolean  cond)

If the boolean argument is true, makes this component visible. If false, makes this component invisible.

size()

Returns: the current size of this component.

toString()

Returns: a string representation of this component.

update(Graphics  g)

Updates this component.  The AWT calls the update method in response to a call to repaint. The appearance of the component on the screen has not changed since the last call to update or paint.This metod performs the following :

Clears this component by filling it with the background color.

Sets the color of the graphics context to be the foreground color of this component.

Calls this component's paint method to completely redraw this component.

The ( 0, 0) coordinate of the graphics context is the top-left corner of this components. The clipping region of the graphics context is the bounding rectangle of this component

validate()

Validates this component if necessary. This component and any subcomponents are laid out again, if necessary.

Class Container

Container is the abstract superclass representing all components that can hold other components. Each container may be associated with a LayoutManager instance that determines the position of each of the container's subcomponents.

public  abstract  class  java.awt.Container	extends  java.awt.Component  {
			// 	Methods
		public Component add(Component  comp);	
		public Component add(Component  comp, int  pos);	 
		public Component add(String  name, Component  comp);	 
		public void addNotify(); 
		public int countComponents();	 
		public void deliverEvent(Event  evt);	 
		public Component getComponent(int  n);	 
		public Component[] getComponents();	 
		public LayoutManager getLayout(); 
		public Insets insets();	 
		public void layout();	 
		public void  list(PrintStream  out, int  indent); 
		public Component locate(int  x, int  y);	 
		public Dimension minimumSize(); 
		public void paintComponents(Graphics  g);	 
		protected String paramString();	 
		public Dimension preferredSize();	 
		public void printComponents(Graphics  g);	 
		public void remove(Component  comp);	 
		public void removeAll();	 
		public void removeNotify();	 
		public void setLayout(LayoutManager  mgr);	 
		public void validate(); 
	}

 

Table 4.11

Method

Description

add(Component  comp)

Adds the specified component to the end of this container.

Returns: the component argument.

add(Component  comp, int  pos)

Adds the specified component to this container at the given position.

Returns: the component argument.

add(String  name, Component   comp)

Adds the specified component to the end of this container. Also add the component to the layout manager using the name specified. Returns: the component argument.

addNotify()

Notifies this container to create a peer. The addNotify method of Container calls the addNotify method for each of the components in this container. It then calls its superclass's addNotify method to indicate that the container needs to be laid out again since its size may have changed.

Most applications do not call this method directly.

countComponents()

Returns: the number of components in this container.

deliverEvent(Event  evt)

Delivers an event to this component or one of its subcomponents.   The deliverEvent method of Container determines whether this event properly belongs to one of its subcomponents. If so, it translates the event into the subcomponent's coordinate system and delivers the event to it by calling its deliverEvent method.  If the event doesn't properly belong to one of the container's subcomponents, it calls this container's postEvent method on the event.

getComponent(int  n)

Returns: the nth component in this container.

Throws : ArrayIndexOutOfBoundsException, if the nth value does not exist.

getComponents()

Returns: an array of all the component in this container. 

getLayout()

Returns: the layout manager for this container.

insets()

Determines the insets of this container, which indicate the size of the container's border.  A Frame, for example, has a top inset that corresponds to the height of the frame's title bar.   The insets method of Container calls the insets method of this container's peer, if the container has a peer. Otherwise it returns the inset new Inset(0, 0, 0, 0), which indicates that the container has no border.

Returns: the insets of this container.

layout()

Lays out this container. The layout method of Container calls the layoutContainer method of the container's layout manager. Most applications do not call this method directly. This method is called when a container calls its validate method.

list(PrintStream  out, int                            indent)

Prints a listing of this container to the specified output stream. The listing starts at the specified indentation. The list method of Container prints itself by calling its superclass's list method and then calls list on each of its subcomponents with and indentation of indent + 1 .

locate(int  x, int  y)

Determines the component or subcomponent of this container that contains the (x, y) coordinate. This method only looks one level deep. If the point(x, y)is inside a subcomponent that itself has subcomponents, it does not go looking down the subcomponent tree. The locate method of Container first determines if the (x, y)coordinate is inside its own boundaries. If not, it returns null immediately. If the coordinate is inside its boundaries, it calls inside on each of the subcomponents; if any of those calls to returns true, that subcomponent is returned; otherwise the container target object is returned.

Returns: this container or one of its subcomponent that contains the (x, y) coordinate; null if the coordinate is outside this container.

minimumSize()

Determines the minimum size of this container. The minimumSize method of Container checks to see if this container has a layout manager . If so, its minimumLayoutSize method is called. Otherwise, its superclass's minimumSize method is called.Returns: the minimum size of this container.

paintComponents(Graphics  g)

Paints each of the components in th is container.

paramString()

Returns the parameter string representing the state of this container. This string is useful for debugging. Returns: the parameter string of this container. 

preferredSize()

Determines the preferred size of this container. The preferredSize method of Container checks to see if this container has a layout manager . If so, its preferredLayoutSize method is called. Otherwise, its superclass's preferredSize method is called.

Returns: the minimum size of this container. 

printComponents(Graphics  g)

Prints each of the components in this container.

remove(Component  comp)

Removes the specified component from this container. This method also causes the component to call its removeNotify method to remove its peer.

removeAll()

Removes all the components from this container. This method also causes all the components in the container to call their removeNotify method to remove their peers.

removeNotify()

Notifies this container and all its subcomponents to destroy their peers.

setLayout(LayoutManager  mgr)

Sets the layout manager for this container.

validate()

Validates this container and all of its subcomponents. The AWT uses this method to have a container be laid out again after adding or otherwise changing the components it contains.

Class Dialog

This class represents a dialog window, a window that takes input from the user. Dialogs are intended to be temporary windows. They present specific timely information to the user, or they allow the user to specify options for the current operation. The AWT sends the dialog window all mouse, keyboard, and focus events that occur over it. By default, the dialog window is invisible. The application must use the show method to cause the dialog window to appear. The default layout for a dialog is BorderLayout.

public  class  java.awt.Dialog extends  java.awt.Window  
	{
		// 	Constructors
		public Dialog(Frame  parent, boolean  modal);
		/*	Creates a dialog window that is initially invisible. If the modal flag is true, the dialog window grabs all input from the user. 
		*/	 
		public Dialog(Frame  parent, String  title, boolean  modal);
		/*	Creates a titled dialog window that is initially invisible. If the modal flag is true, then the dialog box grabs all input from the user.
		*/
		// 	Methods
		public void addNotify();	 
		public String getTitle();	 
		public boolean isModal();	 
		public boolean isResizable();	 
		protected String paramString();	 
		public void setResizable(boolean  resizable); 
		public void setTitle(String  title);	 
	}

Table 4.12

Method

Description

addNotify()

This method calls the createDialog method of this object's toolkit in order to create a DialogPeer for this dialog window. This peer allows the application to change the look of a dialog window without changing its functionality. Most applications do not call this method directly.

getTitle()

Returns: the title of this dialog window.

isModal()

Returns: true if this dialog window is modal; false otherwise.

isResizable()

Indicates whether this dialog window is resizable. By default, a dialog window is resizable. Returns: true if the user can resize this dialog window; false otherwise.

paramString()

Returns the parameter string representing the state of this dialog window. This string is useful for debugging.

setResizable(boolean  resizable)

Sets the resizable flag for this dialog window.

setTitle(String  title)

Sets the title of this dialog window.

Class Dimension

This class encapsulates the width and height of a component in a single object.

public  class  java.awt.Dimension extends  java.lang.Object  
	{
	// 	Member elements
	public int height; 
	//	The height of the component.
	public int width;	 
	//	The width of the component.

	// 	Constructors
	public Dimension(); 
	//	Creates a Dimension with a width of zero and a height of zero.
	public Dimension(Dimension  d); 
	//	Creates a Dimension whose width and height are the same as the argument.
	public Dimension(int  width, int  height);	 
	//	Creates a Dimension with the specified width and height.

	// 	Methods
	public String toString(); 
	//	Returns: a string representation of this dimension.
	}

Class Event

This is a platform-independent class that encapsulates user events from the local Graphical User Interface (GUI) platform.

public  class  java.awt.Event extends  java.lang.Object  
{
		// 	Member elements 
		public Object arg;	 
		//	An arbitrary argument of the event. The value of this field depends on the type of event.
		public int clickCount;	
		//	For MOUSE_DOWN events, this field indicates the number of consecutive clicks. For other events, it is zero. 
		public Event evt;	 
		//	For MOUSE_DOWN events, this field indicates the number of consecutive clicks. For other events, it is zero.
		public int id;	
		/*	The type of the event.  Possible values for the id  field :	
		public final static int ACTION_EVENT;	//This event indicates that the user wants some action to occur. 
		public final static int GOT_FOCUS;	 	// A component gained the focus.
		public final static int KEY_ACTION; 	// The user has pressed an "action" key.
		public final static int KEY_ACTION_RELEASE;	//The user has released an "action" key. 
		public final static int KEY_PRESS;	 	// The user has pressed a normal key.
		public final static int KEY_RELEASE;	// The user has released a normal key. 	 
		public final static int LIST_DESELECT;	//An item in a list has been deselected 
		public final static int LIST_SELECT;	//An item in a list has been  selected 
		public final static int LOAD_FILE;	 	// A file loading event.
		public final static int LOST_FOCUS;	 	// A component lost the focus.
		public final static int MOUSE_DOWN;	//The user has pressed the mouse button. 
		public final static int MOUSE_DRAG;	//The user has moved the mouse with a button pushed. 
		public final static int MOUSE_ENTER; 	// The mouse has entered a component.
		public final static int MOUSE_EXIT;	// The mouse has exited a component.
		public final static int MOUSE_MOVE;	//The mouse has moved with no button pressed.	 
		public final static int MOUSE_UP;	 	// The user has released the mouse button.
		public final static int SAVE_FILE;	 	// A file saving event.
		public final static int SCROLL_ABSOLUTE; // The user has moved the bubble in a scroll bar.                                                                                                                          
		public final static int SCROLL_LINE_DOWN; //The user has pushed the "line down" area of a scroll bar.                                                                                                                         	 
		public final static int SCROLL_LINE_UP;	 // The user has pushed the "line up" area of a scroll bar.                                                                                                                              
		public final static int SCROLL_PAGE_DOWN;//The user has pushed the "page down" area of a scroll bar.                                                                                                                        	 
		public final static int SCROLL_PAGE_UP;	 // The user has pushed the "page up"                                                                                                                              
		public final static int WINDOW_DEICONIFY;//The user has asked the window  area of a scroll bar.                                                                                                                                  
		public final static int WINDOW_DESTROY; // The user has asked the window manager to de-iconify the window.                                                                                                                                 
		public final static int WINDOW_EXPOSE; // A window has become exposed. manager to kill the window.
		public final static int WINDOW_ICONIFY;	//The user has asked the window manager to iconify the window. 
		public final static int WINDOW_MOVED; // The window has moved.
																	/*
		public int key; 
		/*	The key that was pressed in a keyboard event. Possible values for the key field  when the action is KEY_ACTION or KEY_ACTION_RELEASE:  /* 
		public final static int DOWN;	 
		public final static int END;	 
		public final static int F1;	 
		public final static int F2;	 
		public final static int F3; 
		public final static int F4; 
		public final static int F5;	 
		public final static int F6;	 
		public final static int F7; 
		public final static int F8;	 
		public final static int F9;	 
		public final static int F10; 
		public final static int F11;	 
		public final static int F12;	 
		public final static int HOME; 
		public final static int LEFT; 
		public final static int PGDN; 
		public final static int PGUP;	 
		public final static int RIGHT; 
		public final static int UP;	


		public int modifiers;
		/*	The state of the modifier keys. Possible masks for the modifiers field 
		public final static int ALT_MASK	
		/*	This flag indicates that the "alt" key was down when the event occurred. For mouse events, this flag indicates that the middle button was pressed or                                                                      released. */
		public final static int CTRL_MASK;	
		//	This flag indicates that the control key was down when the event occurred. 
		public final static int META_MASK; 
		//	This flag indicates that the meta key was down when the event occurred. For mouse events, this flag indicates that the right button was pressed or released.

		public final static int SHIFT_MASK;	
		//	This flag indicates that the shift key was down when the event occurred.
		public Object target;
		/*	The target component. This indicates the component over which the event occurred or with which the event is  associated.
		*/ 	 
		public long when;	 
		//	The time stamp of the event.
		public int x;
		//	The x coordinate of the event. 	 
		public int y;	
		//	The y coordinate of the event.

		
		// 	Constructors
		public Event(Object  target, int  id, Object  arg);	
		//	Creates an Event with the specified target component, event type, and argument. 
		public Event(Object  target, long  when, int id,	 int  x, int  y, 
												  int  key, int  modifiers);
		/*	Creates an Event with the specified target component, time stamp, event type, x and y coordinates, keyboard key, state of the modifier keys, and an argument set to null. 
		*/
		public Event(Object  target, long  when, int id, int  x, int  y,
									 int  key, int  modifiers, Object  arg);
		/*	Creates an Event with the specified target component, time stamp, event type, x and y coordinates, keyboard key,  state of the modifier keys, and argument.
		*/

		// 	Methods
		public boolean controlDown(); 
		public boolean metaDown(); 
		protected String paramString();	 
		public boolean shiftDown();	 
		public String toString();	 
		public void translate(int  dX, int  dY);	 
	}

Table 4.14

Method

Description

controlDown()

Returns: true if this event indicates that the control key was down; false otherwise.

metaDown()

Returns: true if this event indicates that the meta key was down; false otherwise.

paramString()

Returns the parameter string representing this event. This string is useful for debugging.

shiftDown()

Returns: true if this event indicates that the shift key was down; false otherwise.

toString()

Returns: a string representation of this event. 

translate(int  dX, int   dY)

Translates this event so that its x and y position are increased by dx and dy respectively.

Class FileDialog

The class FileDialog displays a dialog window from which the user can select a file.Since it is a modal dialog, when its show method is called, it blocks the rest of the application until the user has chosen a file. The AWT sends the file dialog window all mouse, keyboard, and focus events that occur over it.

public  class  java.awt.FileDialog extends  java.awt.Dialog  
	{
		// 	Member elements
		public final static int LOAD;	  
		//	This constant value indicates that the file dialog window is intended to determine a file from which to read.
		public final static int SAVE;	 
		//	This constant value indicates that the file dialog window is intended to determine a file to which to write.

		// 	Constructors
		public FileDialog(Frame  parent, String  title);
		/*	Creates a file dialog window with the specified title for loading a file. The files shown are those in the current directory. 
		*/	 
		public FileDialog(Frame  parent, String  title, int  mode);	
		/*	Creates a file dialog window with the specified title for loading or saving a file. The mode   argument must have the value LOAD   or to SAVE . The value LOAD indicates that the file dialog is finding a file to read. The value SAVE indicates that the file dialog is finding a place to write a file. 
		*/
		// 	Methods
		public void addNotify();	 
		public String getDirectory(); 
		public String getFile();	 
		public FilenameFilter getFilenameFilter();	 
		public int getMode();	 
		protected String paramString(); 
		public void setDirectory(String  dir);	 
		public void setFile(String  file);	 
		public void setFilenameFilter(FilenameFilter  filter);	 
	}

Table 4.15

Method

Description

addNotify()

This method calls the createFileDialog method of this object's toolkit in order to create a FileDialogPeer for this file dialog window. The peer allows the application to change the look of a file dialog window without changing its functionality. Most applications do not call this method directly.>

getDirectory()

Returns: the directory of this dialog.

getFile()

Returns: the currently selected file of this file dialog window, or null if none is selected.

getFilenameFilter()

Determines this file dialog's filename filter. A filename filter allows the user to specify which files appear in the file dialog window.Returns:  this file dialog's filename filter.

getMode()

Indicates whether this file dialog box is for loading from a file or for saving to a file.

Returns: the mode of this file dialog window; the value is either LOAD or Save

paramString()

Returns the parameter string representing the state of this file dialog window. This string is useful for debugging.Returns: the parameter string of this file dialog window.

setDirectory(String  dir)

Sets the directory of this file dialog window to be the specified directory.

setFile(String  file)

Sets the selected file for this file dialog window to be the specified file. This file becomes the default file if it is set before the file dialog window is first shown.

setFilenameFilter(FilenameFilter  filter)

Sets the filename filter for this file dialog window to the specified filter.

Class FlowLayout

A Flow layout arranges components in a left-to-right flow, much like lines of text in a paragraph. Flow layouts are typically used to arrange buttons in a panel.

public  class  java.awt.FlowLayout extends  java.lang.Object  
    implements java.awt.LayoutManager   
	{
		// 	Member elements
		public final static int CENTER;	
		//	This value indicates that each row of components should be centered. 
		public final static int LEFT; 
		//	This value indicates that each row of components should be left justified.
		public final static int RIGHT;	
		//	This value indicates that each row of components should be right justified. 
		// 	Constructors
		public FlowLayout();
		//	Creates a new flow layout manager with a centered alignment and a default 5-pixel horizontal and vertical gap. 	 
		public FlowLayout(int  align);	 
		/*	Creates a new flow layout manager with the indicated alignment and a default 5-pixel horizontal and vertical gap. The alignment argument must be one of FlowLayout.LEFT, FlowLayout.RIGHT, or FlowLayout.CENTER.
		*/
		public FlowLayout(int  align, int  hgap, int vgap);
		/*	Creates a new flow layout manager with the indicated alignment and the indicated horizontal and vertical gaps. The alignment argument must be one of FlowLayout.LEFT, FlowLayout.RIGHT, or FlowLayout.CENTER. 	 
		*/
		// 	Methods
		public void addLayoutComponent(String  name, Component  comp);
		public void layoutContainer(Container  target);	 
		public Dimension minimumLayoutSize(Container  target); 
		public Dimension preferredLayoutSize(Container  target);	 
		public void removeLayoutComponent(Component  comp); 
		public String toString(); 
	}

 Table 4.16

Method

Description

addLayoutComponent(String  name,                     Component  comp)

This method is not used by the flow layout manager.

layoutContainer(Container  target)                          

Lays out the container argument using this layout.This method lets each component take its preferred size.Most applications do not call this method directly. This method is called when a container calls its layout method.

minimumLayoutSize(Container      target)

Determines the minimum size of the target container using this flow layout.  The minimum width needed to lay out the container's components is the total minimum width of each of the components, plus (ncomponents + 1) times the horizontal gap, plus the left and right inset, where ncomponents is the number of components in the container.  The minimum height needed to lay out the container's components is the greatest minimum height of the components, plus twice the vertical gap, plus the top and bottom insets.  Most applications do not call this method directly. This method is called when a container calls its layout method.

Returns : the minimum dimensions needed to lay out the subcomponents of the specified container.

preferredLayoutSize(Container target)

Determines the preferred size of the target container using this flow layout.The preferred width to lay out the container's components is the total preferred width of each of the components, plus (ncomponents + 1) times the horizontal gap, plus the left and right inset, where ncomponents is the number of components in the container. The preferred height to lay out the container's components is the greatest preferred height of the components, plus twice the vertical gap, plus the top and bottom insets.  Most applications do not call this method directly. This method is called when a container calls its preferredSize method.

Returns : the preferred dimensions to lay out the subcomponents of the specified container.

removeLayoutComponent(Component comp)

Removes the specified component from this layout. Most applications do not call this method directly. This method is called when a container calls its remove,or removeAll

toString()

Returns : a string representation of this layout.

Class Font

This class represents a font.


public  class  java.awt.Font extends  java.lang.Object   
	{
		// Member elements
		protected String name;	
		//	The logical name of this font. 
		protected int size;	 
		//	The point size of this font.
		protected int style;
		/*	The style of the font. This is the sum of the constants PLAIN, BOLD, or ITALIC.	Following style are known :     	 
		public final static int BOLD;	 
		public final static int ITALIC;	 
		public final static int PLAIN	 
		*/
		// 	Constructors
		public Font(String  name, int  style, int  size); 
		//	Creates a new font with the specified name, style, and point size.

		// 	Methods
		public boolean equals(Object  obj);	 
		public String getFamily(); 
		public static Font getFont(String  nm);	 
		public static Font getFont(String  nm, Font  font);	 
		public String getName();	 
		public int getSize(); 
		public int getStyle();	 
		public int hashCode(); 
		public boolean isBold();	 
		public boolean isItalic();	 
		public boolean isPlain();	 
		public String toString();	 
	}

Table 4.17

Method

Description

equals(Object  obj)

The result is true if and only if the argument is not null and is a Font object with the same name, same style, and same point size as this Font.

Returns: true if the objects are the same; false otherwise. 

getFamily()

Returns: the platform-specific family name of this font.

getFont(String  nm)

The first argument is treated as the name of a system property to be obtained as if by the method System.getProperty. The string value of this property is then interpreted as a font as described in the getFont method of two argument. If the specified property is not found, null is returned. Returns: the Font value of the property.

getFont(String  nm, Font  font)

The first argument is treated as the name of a system property to be obtained as if by the method System.getProperty The string value of this property is then interpreted as a font. The property value should be one of the following forms:

fontname-style-pointsize fontname-pointsize fontname-style fontname
where style is one of the three strings "bold", "bolditalic" or "italic" and pointsize is a decimal representation of the pointsize.The default style is PLAIN. The default pointsize is 12. If the specified property is not found, the font argument is returned instead.Returns: the Font value of the property.

getName()

Returns: the logical name of this font.

getSize()

Returns: the point size of this font.

getStyle()

Returns: the style of this font.

hashCode()

Returns: a hash code value for this font. 

isBold()

Returns: true if this font is bold; false otherwise.

isItalic()

Returns: true if this font is italic; false otherwise.

isPlain()

Returns: true if this font is neither bold nor italic; false otherwise.

toString()

Returns: a string representation of this font.

Class FontMetrics

This class represents a font metrics object, which gives information about the rendering of a particular font on a particular screen. When an application asks the AWT to place a character at the position (x, y), the character is placed so that its reference point (shown as the dot in the picture on the right) is put at that position. The reference point specifies a horizontal line called the baseline of the character. In normal printing, the baselines of the characters should align. In addition, every character in a font has an ascent, a descent, and an advance width. The ascent is the amount by which the character ascends above the baseline. The descent is the amount by which the character descends below the baseline.

The advance width indicates the position at which AWT should place the next character. If the current character is placed with its reference point at the position (x, y), and the character's advance width is w, then the following character is placed with its reference point at the position x+w. The advance width is often the same as the width of character's bounding box, but need not be so. It particular, slanted and italic fonts often have characters whose top-right corner extends slightly beyond the advance width.

An array of characters or a string can also have an ascent, a descent, and an advance width. The ascent of the array is the maximum ascent of any character in the array. The descent is the maximum descent of any character in the array. The advance width is the sum of the advance widths of each of the characters in the array. The default implementations of these methods are inefficient; they are usually overridden with more efficient toolkit-specific implementations.

public  abstract  class  java.awt.FontMetrics extends  java.lang.Object  
	{
		// 	Member elements
		protected Font font;
		//	The actual font. 	 

		// 	Constructors
		protected FontMetrics(Font  font);
		/*	Creates a new FontMetrics object for finding out height and width information about the specified font and specific character glyphs in that font. 	 
		*/
		// 	Methods
		public int bytesWidth(byte  data[], int  off, int len); 
		public int charsWidth(char  data[], int  off, int len);	 
		public int charWidth(char  ch); 
		public int charWidth(int  ch); 
		public int getAscent();	 
		public int getDescent();	 
		public Font getFont();	 
		public int getHeight();	  
		public int getLeading();	 
		public int getMaxAdvance();	 
		public int getMaxAscent(); 
		public int getMaxDescent();	 
		public int[] getWidths(); 
		public int stringWidth(String  str); 
		public String toString();	 
	}

Table 4.18

Method

Description

bytesWidth(byte  data[] ,int  off, int len)

Returns: the advance width of the subarray of the specified byte array in the font described by this font metric.

charsWidth(char  data[], int  off, int len)

Returns: the advance width of the subarray of the specified char array in the font described by this font metric.

charWidth(char  ch)

Returns: the advance width of the specified char in the font described by this font metric.

charWidth(int  ch)

Returns: the advance width of the specified character in the font described by this font metric.

getAscent()

Determines the font ascent of the font described by this font metric. The font ascent is the distance from the base line to the top of most alphanumeric characters. Some characters in the font may extend above this distance Returns: the font ascent of the font.

getDescent()

Determines the font descent of the font described this font metric. The font descent is the distance from the base line to the bottom of most alphanumeric characters. Some characters in the font may extend below this distance.

getFont()

Returns: the font described by this font metric.

getHeight()

Determines the standard height of a line of text in the font described by this font metric. This standard height is the distance between the baseline of adjacent lines of text. It is computed as the sum

  getLeading() + getAscent() + getDescent()

There is no guarantee that lines of text spaced at this distance must be disjoint; such lines may overlap if some characters overshoot either the standard ascent or the standard descent. Returns: the standard height of the font.

getLeading()

Determines the standard leading of the font described by this font metric. The standard leading (inter-line spacing) is the logical amount of space to be reserved between the descent of one line of text and the ascent of the next line. The height metric is calculated to include this extra space  Returns: the standard leading of the font.

getMaxAdvance()

Returns: the maximum advance width of any character in the font, or -1 if the maximum advance is not known.

getMaxAscent()

Determines the maximum ascent of the font described by this font metric. No character extends further above the baseline than this height.

Returns: the maximum ascent of any character in the font.

getMaxDescent()

Determines the maximum descent of the font described by this font metric. No character extends further below the baseline than this height.

Returns: the maximum descent of any character in the font.

getWidths()

Returns: any array giving the advance widths of the first 256 characters in the font described by this font metric.

stringWidth(String  str)

Returns: the advance width of the specified string in the font described by this font metric.

toString()

Returns: a string representation of this font metric. 

Class Frame

A frame is a top-level window with a title and a border. A frame can also have a menu bar. The AWT sends the frame all mouse, keyboard, and focus events that occur over it.

public  class  java.awt.Frame extends  java.awt.Window  
	implements java.awt.MenuContainer  
	{
		// possible cursor types for the setCursor method
		public final static int CROSSHAIR_CURSOR;	 
		public final static int DEFAULT_CURSOR;	 
		public final static int E_RESIZE_CURSOR;	 
		public final static int HAND_CURSOR;	 
		public final static int MOVE_CURSOR;	 
		public final static int N_RESIZE_CURSOR; 
		public final static int NE_RESIZE_CURSOR;	 
		public final static int NW_RESIZE_CURSOR; 
		public final static int S_RESIZE_CURSOR; 
		public final static int SE_RESIZE_CURSOR;	 
		public final static int SW_RESIZE_CURSOR;	 
		public final static int TEXT_CURSOR;	 
		public final static int W_RESIZE_CURSOR; 
		public final static int WAIT_CURSOR;	 

		// 	Constructors
		public Frame();
		//	Constructs a new frame; it is initially invisible and has no title. 	 
		public Frame(String  title);	 
		//	Constructs a new frame; it is initially invisible and has the specified title.

		// 	Methods
		public void addNotify(); 
		public void dispose(); 
		public int getCursorType();	 
		public Image getIconImage(); 
		public MenuBar getMenuBar(); 
		public String getTitle(); 
		public boolean isResizable();	 
		protected String paramString(); 
		public void remove(MenuComponent  m); 
		public void setCursor(int  cursorType);	 
		public void setIconImage(Image  image);	 
		public void setMenuBar(MenuBar  mb);	 
		public void setResizable(boolean  resizable); 
		public void setTitle(String  title);
    }

Table 4.19

Method

Description

addNotify()

This method calls the createFrame method of this object's toolkit in order to create a FramePeer for this frame. This peer allows the application to change the look of a frame without changing its functionality. Most applications do not call this method directly.

dispose()

Disposes of this frame, its menubar, and any system resources used by this frame.

getCursorType()

Returns: the cursor type of this frame.

getIconImage()

Returns: the icon image for this frame, or null if this frame doesn't have an icon image.

getMenuBar()

Returns: the menu bar for this frame, or null if this frame doesn't have a menu bar.

getTitle()

Returns: the title of this frame, or null if this frame doesn't have a title

isResizable()

Indicates whether this frame is resizable. By default, all frames are resizable.

Returns: true if the user can resize this frame; false otherwise.

paramString()

Returns the parameter string representing the state of this frame. This string is useful for debugging.  Returns: the parameter string of this frame. 

remove(MenuComponent  m)

Removes the specified menu bar from this frame.

setCursor(int  cursorType)

Sets the cursor image for this frame to be one of the predefined cursors.

setIconImage(Image  image)

Sets the image to display when this frame is iconized. The default icon is platform specific. Not all platforms support the concept of iconizing a window.

setMenuBar(MenuBar  mb)

Sets the menubar of this frame to the specified menubar.

setResizable(boolean                          resizable)

Determines whether this frame should be resizable. By default, a frame is resizable.

setTitle(String  title)

Sets the title of this frame to the specified title.

Class Graphics

The Graphics class is the abstract base class for all graphics contexts which allow an application to draw onto components or onto off-screen images. Unless otherwise stated, all graphics operations performed with a graphics context object only modify bits within the graphic context's clipping region. All drawing or writing is done in the current color using the current paint mode and in the current font..

public  abstract  class  java.awt.Graphics
   	extends  java.lang.Object   
	{
    // 	Constructors
	protected Graphics();
	/*	This constructor is the default contructor for a graphics context.  Since Graphics is an abstract class, applications cannot call this constructor directly. Graphics contexts are obtained from other graphics context or are created by a component. 
	*/

    // 	Methods
    public abstract void clearRect(int  x, int  y, int width, int  height);
    public abstract void clipRect(int  x, int  y, int width, int height);
    public abstract void copyArea(int  x, int  y, int  width, int  height, int  dx, int  dy);
                                                           
    public abstract Graphics create();	 
    public Graphics create(int  x, int  y,int  width, int  height);
    public abstract void dispose();	 
    public void draw3DRect(int  x, int  y, int  width, int  height,  boolean  raised);
                                                        
    public abstract void drawArc(int  x, int  y, int  width, int  height,int  startAngle, int  arcAngle);
    public void drawBytes(byte  data[], int  offset, int  length, int  x, int  y);
                                                           
    public void drawChars(char  data[], int  offset, int  length, int  x, int  y);
                                                           
    public abstract boolean drawImage(Image  img, int  x, int  y,Color  bgcolor,ImageObserver  observer);
    public abstract boolean drawImage(Image  img, int  x,int  y, ImageObserver  observer);
    public abstract boolean drawImage(Image  img, int  x, int  y,int  width, int  height, Color  bgcolor, ImageObserver  observer);
    public abstract boolean drawImage(Image  img, int  x, int  y,int  width, int  height, ImageObserver  observer);
    public abstract void drawLine(int  x1, int  y1, int  x2,  int  y2);
    public abstract void drawOval(int  x, int  y, int width, int  height);
    public abstract void drawPolygon(int  xPoints[], int yPoints[],int  nPoints);
    public void drawPolygon(Polygon  p);	 
    public void drawRect(int  x, int  y,int  width, int  height);
    public abstract void drawRoundRect(int  x, int  y, int  width,int  height, int  arcWidth, int arcHeight);
    public abstract void drawString(String  str, int  x, int  y);
    public void fill3DRect(int  x, int  y, int  width, int  height,boolean  raised);
    public abstract void fillArc(int  x, int  y, int  width, int  height,int  startAngle, int  arcAngle);
    public abstract void fillOval(int  x, int  y, int  width, int  height);
    public abstract void fillPolygon(int  xPoints[], int  yPoints[],int  nPoints);
    public void fillPolygon(Polygon  p);	 
    public abstract void fillRect(int  x, int  y, int  width,  int  height);
    public abstract void fillRoundRect(int  x, int  y, int  width, int height,int  arcWidth,  int  arcHeight);
    public void finalize();	 
    public abstract Rectangle getClipRect();	 
    public abstract Color getColor();	 
    public abstract Font getFont(); 
    public FontMetrics getFontMetrics(); 
    public abstract FontMetrics getFontMetrics(Font  f);	 
    public abstract void setColor(Color  c);	 
    public abstract void setFont(Font  font);	 
    public abstract void setPaintMode(); 
    public abstract void setXORMode(Color  c1); 
    public String toString();	 
    public abstract void   translate(int  x, int  y); 
}

Table 4.20 

Method

Description

clearRect(...)

Clears the specified rectangle by filling it with the background color of the screen.This operation does not use the current paint mode.

clipRect(...)

Sets a clipping rectangle for this graphics context. The resulting clipping area is the intersection of the current clipping area and the specified rectangle  Graphics operations performed with this graphics context have no effect outside the clipping area.

copyArea( ...)

Copies an area. The source is the rectangle with origin (x, y) , and size specified by the width and height arguments. The destination is the rectangle with origin and (x +dx, y+dy) the same width and height. The clipping rectangle of this graphics context affects only the destination, not the source.

create()             

Returns: a new graphics context that is a copy of this graphics context.

create(int  x, int  y,int  width, int  height)

Creates a new graphics context The new graphics context is identical to this graphics context, except in two respects:

v     The new context is translated by (x, y) . That is to say, the point (0, 0) in the new graphics context is the same as (x, y) in this graphics context.

v     The graphics context has an additional clipping rectangle with origin (0, 0)and size specified by the width and height arguments, in addition to whatever (translated) clipping rectangle it inherited from this graphics context.

dispose()                 

Disposes of this graphics context.  The graphics context cannot be used after being disposed.

draw3DRect( ...)

Draws a highlighted 3-D rectangle.

drawArc( ...)

Draws a single circular or elliptical arc.  The center of the arc is the center of the rectangle whose origin is (x, y)  and whose size is specified by the width and height arguments.  The two axes of the arc are given by the width and height arguments.    The arc is drawn from startAngle to startAngle + arcAngle. The start angle and arc angle are in degrees, not radians. A start angle of 0 indicates the 3-o'clock position. A positive arc angle indicates a counter-clockwise rotation; a negative arc angle indicates a clockwise rotation.

drawBytes( ...)

Draws the text given by the specified byte array using this graphics context's current font and color. The baseline of the first character is at position (x, y)in this graphics context's coordinate system.

drawChars( ...)

Draws the text given by the specified character array using this graphics context's current font and color. The baseline of the first character is at position .

drawImage(Image  img, int  x, int  y,  Color  bgcolor,ImageObserver  observer)

Draws the specified image with its top left corner at (x, y) in this graphics context's coordinate space. Transparent pixels in the image are drawn in the specified background color. If the image has not yet been completely loaded, the image observer's imageUpdate method is notified as more of the image becomes available.Returns: true if all bits of the image are available; false otherwise.

drawImage(Image  img, int  x, int  y,ImageObserver  observer)

Draws the specified image with its top left corner at (x, y) in this graphics context's coordinate space. Transparent pixels in the image do not affect whatever pixels are already there.If the image has not yet been completely loaded, the image observer's imageUpdate method is notified as more of the image becomes available.Returns: true if all bits of the image are available; false otherwise.

drawImage(Image  img, int  x, int  y,int  width, int  height,..)

Draws the specified image inside the specified rectangle of this graphics context's coordinate space. The image is scaled if necessary. Transparent pixels in the image are drawn in the specified background color. If the image has not yet been completely loaded, the image observer's imageUpdate method is notified as more of the image becomes available.>

drawLine( ...)

    Draws a line from (x1, y1) to (x2, y2) in this graphics context's coordinate system.The line is drawn below and to the right of the logical coordinates

drawOval( ...)

    Draws a circle or an ellipse such that it fits within the rectangle specified by the x,y, width and height arguments. The center of the oval is the center of the rectangle whose origin is (x, y) is this graphics context's coordinate system and whose size is specified by the width and height arguments.

drawPolygon(int  xPoints[], int yPoints[],int  nPoints)

Draws a closed polygon defined by an array of x points and y points.This method draws the polygon defined by npoint line segments, where the first npoint-1 line segments are lines segments from (xPoints[i-1], yPoints[i-1]) to(xPoints[i], yPoints[i]), for 1<=i <= nPoints. The last line segment starts at the final point and ends at the first point

drawPolygon(Polygon  p)                          

Draws a polygon defined by the specified polygon argument.

drawRect( ...)

  Draws the outline of the specified rectangle using the current color.The left and right edges of the rectangle are at x and x+width respectively. The top and bottom edges of the rectangle are at y and y+height. respectively.

drawRoundRect( ...)

Draws an outlined round-cornered rectangle using this graphics context's current color. The left and right edges of the rectangle are at x and x + width respectively. The top and bottom edges of the rectangle are at y and y +height.

drawString( ...)        

Draws the string using this graphics context's current font and color. The baseline of the first character is at position(x, y) in the graphics context's coordinate system.

fill3DRect( ...)

Draws a highlighted 3-D rectangle that is filled with this graphics context's current color.

fillArc(...)

Draws a single circular or elliptical arc that is filled with this graphics context's current color. The result is a pie shape. The center of the arc is the center of the rectangle whose origin is (x, y)and whose size is specified by the width and height arguments. The two axes of the arc are given by the width and height arguments. The arc is drawn from startAngle to startAngle + arcAngle. The start angle and arc angle are in degrees, not radians. A start angle of 0 indicates the 3-o'clock position. A positive arc angle indicates a counter-clockwise rotation; a negative arc angle indicates a clockwise rotation.

fillOval( ...)               

Draws a filled circle or a filled ellipse using this graphics context's current color. The center of the oval is the center of the rectangle whose origin is (x, y) is the graphics context's coordinate system and whose size is specified by the width and height arguments.

fillPolygon(int  xPoints[], int  yPoints[], int  nPoints)         

Fills a polygon defined by an array of x points and y points with this graphics context's current color. This method fills the polygon defined by npoint line segments, where the first npoint-1 line segments are lines segments from (xPoints[i-1], yPoints[i-1]) to (xPoints[i], yPoints[i]), for 1<= I <= nPoints. The last line segment starts at the final point and ends at the first point. The area inside the polygon is defined using an "even-odd" fill rule, also known as the "alternating rule."

fillPolygon(Polygon  p)

Fills a polygon defined by the specified polygon argument with this graphics context's current color. The area inside the polygon is defined using an "even-odd" fill rule, also known as the "alternating rule."

fillRect( ...)

Fills the specified rectangle with this graphics context's current color. The left and right edges are at x and x +width -1 respectively. The top and bottom edges are at y and y + height -1 respectively.

fillRoundRect( ....)

Fills an outlined rounded corner rectangle with this graphics context's current color. The left and right edges are at x and x + width - 1 respectively. The top and bottom edges are at y and y + height - 1 respectively.

finalize()                              

The finalize method ensures that this graphics context's dispose method is called when this graphics context is no longer referenced.

getClipRect()

Returns: the bounding rectangle of this graphics context's clipping area.

getColor()

Returns: this graphics context's current color.

getFont()

Returns: this graphics context's current font.

getFontMetrics()

Returns: this font metrics of the graphics context's current font.

getFontMetrics(Font  f)

Returns: the font metrics for the specified font.

setColor(Color  c)

Sets this graphics context's current color to the specified color. All subsequent graphics operations using this graphics context use this specified color.

setFont(Font  font)

Sets this graphics context's font to the specified font. All subsequent text operations (such as drawString, drawBytes , and drawChars ) using this graphics context use this font.

setPaintMode()

Sets the paint mode of this graphics context to overwrite the destination with this graphics context's current color.

setXORMode(Color  c1)

Sets the paint mode of this graphics context to alternate between this graphics context's current color and the new specified color.  When drawing operations are performed, pixels which are the current color are changed to the specified color and vice versa.  Pixels that are of colors other than those two colors are changed in an unpredictable, but reversible manner; if the same figure is drawn twice then all pixels are restored to their original values.

toString()

Returns: a string representation of this graphics context.

translate(int  x, int  y)

Modifies this graphics context so that its new origin corresponds to the point (x,y)in this graphics context's original coordinate system.

Class GridBagConstraints

The GridBagConstraints class specifies constraints for components that are laid out using the GridBagLayout class.

public  class  java.awt.GridBagConstraints extends  java.lang.Object  
    implements java.lang.Cloneable  
	{
		// 	Member elements
		public int anchor;	 
		/*	This field is used when the component is smaller than its display area. It determines where, within the area, to place the component. Valid values are the following :	
		public final static int CENTER;	 
		public final static int EAST;	
		public final static int NORTH;	 
		public final static int NORTHEAST;	 
		public final static int NORTHWEST;	 
		public final static int SOUTH; 
		public final static int SOUTHEAST;	 
		public final static int SOUTHWEST; 
		public final static int WEST; 
		The default value is GridBagConstraints.CENTER.
		*/
				
		public int fill;
		/*	the fill field has one of the following values	:
		public final static int BOTH;	
		public final static int HORIZONTAL; 
		public final static int NONE;	
		public final static int VERTICAL;

		This field is used when the component's display area is larger than the component's requested size. It determine whether to resize the component, and if so, how .Valid values are the following : 

		
  • GridBagConstraint.NONE : Do not resize the component.
  • GridBagConstraint.HORIZONTAL : Make the component wide enough to fill its display area horizontally, but don't change its height.
  • GridBagConstraint.VERTICAL : Make the component tall enough to fill its display area vertically, but don't change its width.
  • GridBagConstraint.BOTH : Make the component fill its display area entirely. The default value is GridBagConstraint.NONE. */ public int gridheight; /* Specifies the number of cells in a column for the component's display area. Use GridBagConstraints.REMAINDER to specify that the component be the last one in its column. Use GridBagConstraints.RELATIVE to specify that the component be the next to last one in its column. The default value is 1. */ public int gridwidth; /* Specifies the number of cells in a row for the the component's display area.. Use GridBagConstraints.REMAINDER to specify that the component be the last one in its row. Use GridBagConstraints.RELATIVE to specify that the component be the next to last one in its row. The default value is 1. */ public int gridx; /* Specifies the cell at the left of the component's display area, where the leftmost cell has gridx = 0. The value. GriddBagConstraints.RELATIVE specifies that the component be placed just to the right of the component that was added to the container just before this component was added. The default value is GridBagConstraints.RELATIVE. */ public int gridy; /* Specifies the cell at the top of the component's display area, where the topmost cell has gridy = 0. The value GridBagConstraints.RELATIVE specifies that the component be placed just below the component that was added to the container just before this component was added. The default value is GridBagConstraints.Relative. */ /* Note : Possible values for gridheight, gridwidth, gridx, gridy : public final static int REMAINDER; public final static int RELATIVE; */ public Insets insets; /* This field specifies the external padding of the component, the minimum amount of space between the component and the edges of its display area. The default value is new Insets(0, 0, 0, 0); */ public int ipadx; /* This field specifies the internal padding, that is how much space to add to the minimum size of the component. The width of the component is at least its minimum width plus ipadx*2 pixels. The default value is 0. */ public int ipady; /* This field specifies the internal padding, how much to add to the minimum size of the component. The height of the component is at least its minimum height plus ipadx*2 pixels. The default value is 0. */ public double weightx; /* This field specifies how to distribute extra vertical space. The grid bag layout manager calculates the weight of a row to be the maximum weightx of all the components in a row. If the resulting layout is smaller vertically than the area it needs to fill, the extra space is distributed to each row in proportion to its weight. A row that has weight 0 receives no extra space. If all the weights are zero, all the extra space appears between the grids of the cell and the top and bottom edges. The default value of this field is zero. */ public double weighty; /* This field specified how to distribute extra horizontal space. The grid bag layout manager calculates the weight of a column to be the maximum weighty of all the components in a row. If the resulting layout is smaller horizontally than the area it needs to fill, the extra space is distributed to each column in proportion to its weight. A column that has weight 0 receives no extra space. If all the weights are zero, all the extra space appears between the grids of the cell and the right and left edges. The default value of this field is zero. */ // Constructors public GridBagConstraints(); // Creates a grid bag constraint object with all the fields set to their default value. // Methods public Object clone(); // Returns : a copy of this grid bag constraint. }
  • Class GridBagLayout

    The grid bag layout manager is a flexible layout manager that aligns components horizontally and vertically, without requiring that the components be the same size. Each grid bag layout manager uses a rectangular grid of cells, with each component occupying one or more cells (called its display area). Each component in a grid bag layout is associated with a set of constraints contained within a GridBag-Constraints instance that specifies how the component is to be laid out within its display area. The manner in which the grid bag layout manager places a set of components depends on each component's constraints and its minimum size, as well as the preferred size of the components' container. To use a grid bag layout effectively, one or more components must have a customized GridBagConstraints objects created for it.

    public  class  java.awt.GridBagLayout extends  java.lang.Object  
        implements java.awt.LayoutManager   
    		{
    			// 	Member elements
    			protected final static int MAXGRIDSIZE;	
    			/*	MAXGRIDSIZE = 128  : The maximum number of grid positions (both horizontally and vertically) that can be laid out by the grid bag layout. 
    			*/
    			protected final static int MINSIZE;	 
    			//	MINSIZE = 1  : The smallest grid that can be laid out by the grid bag layout.
    			// 	Constructors
    			public GridBagLayout(); 
    			//	Creates a grid bag layout manager.
    			// 	Methods
    			public void addLayoutComponent(String  name, Component  comp);
    			public GridBagConstraints getConstraints(Component  comp);	 
    			public void layoutContainer(Container  target);	 
    			protected GridBagConstraints lookupConstraints(Component  comp);
    			public Dimension minimumLayoutSize(Container  target); 
    			public Dimension preferredLayoutSize(Container  target);	 
    			public void removeLayoutComponent(Component  comp);	 
    			public void	setConstraints(Component  comp, GridBagConstraints constraints);
    			public String toString();	 
    		}
    
    

    Table 4.21 

    Method

    Description

    clearRect(...)

    Clears the specified rectangle by filling it with the background color of the screen. This operation does not use the current paint mode.

    clipRect(...)

    Sets a clipping rectangle for this graphics context. The resulting clipping area is the intersection of the current clipping area and the specified rectangle  Graphics operations performed with this graphics context have no effect outside the clipping area.

    copyArea( ...)

    Copies an area. The source is the rectangle with origin (x, y), and size specified by the width and height arguments. The destination is the rectangle with origin and (x +dx, y+dy) the same width and height. The clipping rectangle of this graphics context affects only the destination, not the source.

    create()             

    Returns: a new graphics context that is a copy of this graphics context.

    create(int  x, int  y,int  width, int  height)

    Creates a new graphics context The new graphics context is identical to this graphics context, except in two respects:
    The new context is translated by (x, y) . That is to say, the point (0, 0) in the new graphics context is the same as (x, y) in this graphics context.
    The graphics context has an additional clipping rectangle with origin (0, 0), and size specified by the width and height arguments, in addition to whatever (translated) clipping rectangle it inherited from this graphics context.

    dispose()                 

    Disposes of this graphics context.  The graphics context cannot be used after being disposed.

    draw3DRect( ...)

    Draws a highlighted 3-D rectangle.

    drawArc( ...)

    Draws a single circular or elliptical arc. The center of the arc is the center of the rectangle whose origin is (x, y) and whose size is specified by the width and height arguments. The two axes of the arc are given by the width and height arguments. The arc is drawn from   startAngle to startAngle + arcAngle.   The start angle and arc angle are in degrees, not radians. A start angle of 0 indicates the 3-o'clock position. A positive arc angle indicates a counter-clockwise rotation; a negative arc angle indicates a clockwise rotation.

    drawBytes( ...)

    Draws the text given by the specified byte array using this graphics context's current font and color. The baseline of the first character is at position (x, y)in this graphics context's coordinate system.

    drawChars( ...)

    Draws the text given by the specified character array using this graphics context's current font and color. The baseline of the first character is at position (x, y) in the graphics context's coordinate system.

    drawImage(Image  img, int  x, int  y,  Color  bgcolor,ImageObserver  observer)

    Draws the specified image with its top left corner at (x, y) in this graphics context's coordinate space. Transparent pixels in the image are drawn in the specified background color. If the image has not yet been completely loaded, the image observer's imageUpdate method is notified as more of the image becomes available.Returns: true if all bits of the image are available; false otherwise.

    drawImage(Image  img, int  x, int  y,ImageObserver  observer)

    Draws the specified image with its top left corner at (x, y) in this graphics context's coordinate space. Transparent pixels in the image do not affect whatever pixels are already there.If the image has not yet been completely loaded, the image observer's imageUpdate method is notified as more of the image becomes available.Returns: true if all bits of the image are available; false otherwise.

    drawImage(Image  img, int  x, int  y,int  width, int  height,..)

    Draws the specified image inside the specified rectangle of this graphics context's coordinate space. The image is scaled if necessary. Transparent pixels in the image are drawn in the specified background color. If the image has not yet been completely loaded, the image observer's imageUpdate method is notified as more of the image becomes available.

    drawLine( ...)

        Draws a line from (x1, y1) to (x2, y2) in this graphics context's coordinate system.The line is drawn below and to the right of the logical coordinates.

    drawOval( ...)

       Draws a circle or an ellipse such that it fits within the rectangle specified by the x,y, width and height arguments. The center of the oval is the center of the rectangle whose origin is (x, y) is this graphics context's coordinate system and whose size is specified by the width and height arguments.

    drawPolygon(int  xPoints[], int yPoints[],int  nPoints)

    Draws a closed polygon defined by an array of x points and y points. This method draws the polygon defined by npoint line segments, where the first npoint-1 line segments are lines segments from (xPoints[i-1], yPoints[i-1]) to (xPoints[i], yPoints[i]), for 1<=i <= nPoints . The last line segment starts at the final point and ends at the first point>

    drawPolygon(Polygon  p)                          

    Draws a polygon defined by the specified polygon argument.

    drawRect( ...)

         Draws the outline of the specified rectangle using the current color. The left and right edges of the rectangle are at x and x+width respectively. The top and bottom edges of the rectangle are at y and y+height respectively.

    drawRoundRect( ...)

    Draws an outlined round-cornered rectangle using this graphics context's current color. The left and right edges of the rectangle are at x and x + width respectively. The top and bottom edges of the rectangle are at y and y +height.

    drawString( ...)        

    Draws the string using this graphics context's current font and color. The baseline of the first character is at position (x, y) in the graphics context's coordinate system.

    fill3DRect( ...)

    Draws a highlighted 3-D rectangle that is filled with this graphics context's current color.

    fillArc(...)

    Draws a single circular or elliptical arc that is filled with this graphics context's current color. The result is a pie shape.  The center of the arc is the center of the rectangle whose origin is (x, y)and whose size is specified by the width and height arguments. The two axes of the arc are given by the width and height arguments.  The arc is drawn from startAngle to startAngle + arcAngle. The start angle and arc angle are in degrees, not radians.      A start angle of 0 indicates the 3-o'clock position. A positive arc angle indicates a counter-clockwise rotation; a negative arc angle indicates a clockwise rotation.

    fillOval( ...)               

    Draws a filled circle or a filled ellipse using this graphics context's current color.  The center of the oval is the center of the rectangle whose origin is (x, y) is the graphics context's coordinate system and whose size is specified by the width and height arguments.

    fillPolygon(int  xPoints[], int  yPoints[], int  nPoints)         

    Fills a polygon defined by an array of x points and y points with this graphics context's current color. This method fills the polygon defined by npoint line segments, where the first npoint-1 line segments are lines segments from (xPoints[i-1], yPoints[i-1]) to (xPoints[i], yPoints[i]), for 1<= I <= nPoints.The last line segment starts at the final point and ends at the first point.

    The area inside the polygon is defined using an "even-odd" fill rule, also known as the "alternating rule."

    fillPolygon(Polygon  p)

    Fills a polygon defined by the specified polygon argument with this graphics context's current color. The area inside the polygon is defined using an "even-odd" fill rule, also known as the "alternating rule."

    fillRect( ...)

    Fills the specified rectangle with this graphics context's current color. The left and right edges are at x and x +width -1 respectively. The top and bottom edges are at y and y + height -1 respectively.

    fillRoundRect( ....)

    Fills an outlined rounded corner rectangle with this graphics context's current color. The left and right edges are at x and x + width - 1 respectively. The top and bottom edges are at y and y + height - 1 respectively.

    finalize()                              

    The finalize method ensures that this graphics context's dispose method is called when this graphics context is no longer referenced.

    getClipRect()

    Returns: the bounding rectangle of this graphics context's clipping area.

    getColor()

    Returns: this graphics context's current color.

    getFont()

    Returns: this graphics context's current font.

    getFontMetrics()

    Returns: this font metrics of the graphics context's current font.

    getFontMetrics(Font  f)

    Returns: the font metrics for the specified font.

    setColor(Color  c)

    Sets this graphics context's current color to the specified color. All subsequent graphics operations using this graphics context use this specified color.

    setFont(Font  font)

    Sets this graphics context's font to the specified font. All subsequent text operations (such as drawString, drawBytes , and drawChars ) using this graphics context use this font.

    setPaintMode()

    Sets the paint mode of this graphics context to overwrite the destination with this graphics context's current color.

    setXORMode(Color  c1)

    Sets the paint mode of this graphics context to alternate between this graphics context's current color and the new specified color.  When drawing operations are performed, pixels which are the current color are changed to the specified color and vice versa.  Pixels that are of colors other than those two colors are changed in an unpredictable, but reversible manner; if the same figure is drawn twice then all pixels are restored to their original values.

    toString()

    Returns: a string representation of this graphics context.

    translate(int  x, int  y)

    Modifies this graphics context so that its new origin corresponds to the point (x,y) in this graphics context's original coordinate system.

    Class GridLayout

    This grid layout manager causes the container's components to be laid out in a rectangular grid. The container is split into equal-sized rectangles: one component is placed into each rectangle.

    public  class  java.awt.GridLayout extends  java.lang.Object  
        implements java.awt.LayoutManager   
    	{
    		// 	Constructors
    		public GridLayout(int  rows, int  cols);	
    		/*	Creates a grid layout with the specified number of rows and columns. All components in the layout are given equal size. One, but not both of rows and columns can be zero, which means that any number of objects can be placed in a row or in a column. 
    		*/
    		public GridLayout(int  rows, int  cols, int  hgap, int  vgap);
    		/*	Creates a grid layout with the specified number of rows and columns. All components in the layout are given equal size.In addition the horizontal and vertical gaps are set to the specified values. The horizontal gaps are placed at the left and right edge, and between each of the columns. The vertical gaps are placed at the top and bottom edge, and between each of the rows. One, but not both of rows and columns can be zero, which means that any number of objects can be placed in a row or in a column.
    		*/
    		// 	Methods
    		public void addLayoutComponent(String  name, Component  comp);
    		public void layoutContainer(Container  target);	 
    		public Dimension minimumLayoutSize(Container  target);	 
    		public Dimension preferredLayoutSize(Container  target);	 
    		public void removeLayoutComponent(Component  comp);	 
    		public String toString();	 
    	}
    
    

    Table 4.22

    Method

    Description

    addLayoutComponent( ...)

    This method is not used by the grid layout manager.

    layoutContainer(Container  target)

     

    minimumLayoutSize(Container  target)

    Lays out the container argument using this layout. This method reshapes the components in the specified target container in order to satisfy the constraints of the GridLayout object. The grid layout manager determines the size of individual components by dividing the free space in the container into equal-sized portions according to the number of rows and columns in the layout. The container's free space equals the container's size minus any insets and any specified horizontal or vertical gap. All components in a grid layout are given the same size. Most applications do not call this method directly. This method is called when a container calls its layout method.

    preferredLayoutSize(Container      target)

    Determines the preferred size of the container argument using this grid layout. The preferred width of a grid layout is the largest preferred width of any of the widths in the container times the number of columns, plus the horizontal padding times the number of columns plus 1, plus the left and right insets of the target container.  The preferred height of a grid layout is the largest preferred height of any of the widths in the container times the number of rows, plus the vertical padding times the number of rows plus 1, plus the top and left insets of the target container.  Most applications do not call this method directly. This method is called when a container calls its preferredSize method. Returns: the preferred dimensions to lay out the subcomponents of the specified container.

    removeLayoutComponent(Component  comp)

    This method is not used by the grid layout manager.

    toString()

    Returns: a string representation of this grid layout.

    Class Image

    The abstract class Image is the superclass of all classes that represent graphical images.

    public  abstract  class  java.awt.Image extends  java.lang.Object   
    	{
    		// 	Member elements
    		public final static Object UndefinedProperty;	
    		/*	The UndefinedProperty object should be returned whenever a property which was not defined for a particular image is fetched.
    		*/
    		// Constructors
    		public Image();	
    		//	The default constructor for an image.
    		// 	Methods
    		public abstract void flush();	 
    		public abstract Graphics getGraphics(); 
    		public abstract int getHeight(ImageObserver  observer);	 
    		public abstract Object getProperty(String  name, ImageObserver  observer);
    		public abstract ImageProducer getSource();	 
    		public abstract int getWidth(ImageObserver  observer)	  
    	}
    
    

    Table 4.22

    Method

    Description

    flush()

    Flushes all resources being used by this Image object.  These resources includes any pixel data that is being cached for rendering to the screen as well as any system resources that are being used to store data or pixels for the image.   The Image object is reset to a state similar to when it was first created so that if it is again rendered, the image data must be recreated or fetched again from its source.

    getGraphics()

    Creates a graphics context for drawing to an off-screen image. This method can only be called for off-screen images, which are created with the createImage method with two integer arguments. Returns: a graphics context to draw to the off-screen image.

    getHeight(ImageObserver                 observer)

    Determines the height of this image. If the height is not yet known, the observer is notified later. Returns:  the height of the image, or -1 if the height is not yet known.

    getProperty(String  name,         ImageObserver                observer)

    Gets a property of this image by name.   Individual property names are defined by the various image formats. If a property is not defined for a particular image, this method returns the UndefinedProperty object.   If the properties for this image are not yet known, this method returns null and the ImageObserver object is notified later.  The property name "comment" should be used to store an optional comment which can be presented to the application as a description of the image, its source, or its author. Returns: the value of the named property.

    getSource()

    Returns: the image producer that produces the pixels for this image

    getWidth(ImageObserver                observer)

    Determines the width of this image. If the width is not yet known, the observer is notified later. Returns: the width of this image, or -1 if the width is not yet known.

    Class Insets

    The Insets object is a representation of the borders of a container. It specifies the space that a container must leave at each of its edges. The space can either be a border, blank space, or a title.

    public  class  java.awt.Insets extends  java.lang.Object   
    	implements java.lang.Cloneable   
    	{
    		// 	Member elements
    		public int bottom;		//	The inset from the bottom. 
    		public int left;		//	The inset from the left. 	 
    		public int right;	 	//	The inset from the right.
    		public int top;		//	The inset from the top. 	 
    
    		// 	Constructors
    		public Insets(int  top, int  left, int  bottom, int right);
    		//	Creates and initializes a new Inset with the specified top, left, bottom, and right insets. 	 
    		// 	Methods 
    		public Object clone(); 	//	Returns : a copy of this inset.
    		public String toString();	//	Returns : a string representation of this inset.  	 
    	}
    

    Class Label

    A label is a component for placing text in a container. The text can be changed by the application, but a user cannot edit it directly

    public  class  java.awt.Label extends  java.awt.Component   
    	{
    		// 	Member elements
    		public final static int CENTER; //	Indicates that the label should be centered.
    		public final static int LEFT;	 //	Indicates that the label should be left justified.
    		public final static int RIGHT;// Indicates that the label should be right justified. 	 
    
    		// 	Constructors
    		public Label();	//	Constructs an empty label with whose text is left justified. 	 
    		public Label(String  label);	 //	Constructs a new label with the specified string of text left justified.
    		public Label(String  label, int  alignment);
    		/*	Constructs a new label with the specified string of text and the specified alignment. The alignment value must be one of Label.LEFT, Label.RIGHT, or Label.CENTER. 	 
    		*/
    			// 	Methods
    		public void addNotify();	 
    		public int getAlignment(); 
    		public String getText();	 
    		protected String paramString(); 
    		public void setAlignment(int  alignment);	 
    		public void setText(String  label);	 
    	}
    
    

    Table 4.23

    Method

    Description

    addNotify()

    This method calls the createLabel method of this object's toolkit in order to create a LabelPeer for this label. This peer allows the application to change the look of a label without changing its functionality. Most applications do not call this method directly.

    getAlignment()

    Returns: the current alignment of this label.

    getText()

    Returns: the text of this label.

    paramString()

    Returns the parameter string representing the state of this label. This string is useful for debugging.

    setAlignment(int  alignment)

    Sets the alignment for this label to the specified alignment.

    Throws : IllegalArgumentException, if the improper alignment was given.

    setText(String  label)

    Sets the text for this label to the specified text.

    Class List

    The List component presents the user with a scrolling list of text items. The list can be set up either so that the user can pick one item or to pick multiple items.

    Clicking on an item that isn't selected selects it. Clicking on an item that is already selected deselects it.. Selecting any item causes any other selected item to be automatically deselected. When an item is clicked and becomes selected, AWT sends a list select event to the scrolling list. When an item is clicked and becomes deselected, AWT sends a list deselect event to the scrolling list. The event's target is the scrolling list, and its object is an Integer giving the index of the item in the list. When the user double clicks on an item in a scrolling list, AWT sends an action event to the scrolling list after the list select or deselect event. The event's target is the scrolling list, and its object is the string label of the item selected or deselected. When the user hits return inside a scrolling list, AWT also sends an action event to the scrolling list. The event's target is the scrolling list, and its object is the string label of the last item selected or deselected in the scrolling list.

    If an application wants to perform some action based on an item being selected or deselected, it must override the handleEvent method of the scrolling list or of one of its containing windows.

    public  class  java.awt.List extends  java.awt.Component  
    	{
           	
    		// 	Constructors
    		public List();
    		//	Creates a new scrolling list. Initially there are no visible lines, and only one item can be selected from the list. 		
    		public List(int  rows, boolean  multipleSelections); 
    		/*	Creates a new scrolling list initialized to display the specified number of rows. If the multipleSelections argument is true, then the user can select multiple items at a time from the list. If it is false, only one item at a time can be selected.
    		*/
    		// 	Methods
    		public void addItem(String  item); 
    		public void addItem(String  item, int  index); 
    		public void addNotify();	 
    		public boolean allowsMultipleSelections(); 
    		public void clear();	 
    		public int countItems();	 
    		public void delItem(int  position); 
    		public void delItems(int  start, int  end);	 
    		public void deselect(int  index); 
    		public String getItem(int  index);	 
    		public int getRows();	 
    		public int getSelectedIndex(); 
    		public int[] getSelectedIndexes();	 
    		public String getSelectedItem();	 
    		public String[] getSelectedItems();	 
    		public int getVisibleIndex(); 
    		public boolean isSelected(int  index); 
    		public void makeVisible(int  index);	 
    		public Dimension minimumSize(); 
    		public Dimension minimumSize(int  rows); 
    		protected String paramString();	 
    		public Dimension preferredSize();	 
    		public Dimension preferredSize(int  rows); 
    		public void removeNotify();	 
    		public void replaceItem(String  newValue, int  index);	 
    		public void select(int  index);	 
    		public void setMultipleSelections(boolean  v);
    	}
    
    

    Table 4.24

    Method

    Description

    addItem(String  item)

    Adds the specified string to the end of this scrolling list.

    addItem(String  item, int  index)

    Adds the specified string to this scrolling list at the specified position.  The index argument is 0-based. If the index is -1, or greater than or equal to the number of items already in the list, then the item is added at the end of this list.

    addNotify()

    This method calls the createList method of this object's toolkit in order to create a ListPeer for this scrolling list. This peer allows the application to change the look of a scrolling list without changing its functionality.

    allowsMultipleSelections()

    Returns: true if this scrolling list allows multiple selections; false otherwise.

    clear()

    Removes all items from this scrolling list.

    countItems()

    Returns: the number of items in this list.

    delItem(int  position)

    Deletes the item at the specified position from this scrolling list.

    delItems(int  start, int  end)

    Deletes the items in the range  (start <= item <= end) [NS1]  from this scrolling list.

    deselect(int  index)

    Deselects the item at the specified index of this scrolling list. If the item at the specified index is not selected, or if the index is out of range, then the operation is ignored

    getItem(int  index)

    Returns: the string of this scrolling list at the specified index.

    getRows()

    Returns: the number of visible lines in this scrolling list.

    getSelectedIndex()

    Returns: the index of the selected item on this scrolling list, or -1 if either no items are selected or more than one item is selected.

    getSelectedIndexes()

    Returns: an array of the selected indexes of this scrolling list.

    getSelectedItem()

    Returns: the selected item on this scrolling list, or null if either no items are selected or more than one item is selected.

    getSelectedItems()

    Returns: an array of the selected items on this scrolling list.

    getVisibleIndex()

    Returns: the index of the item in this scrolling list that was last made visible by the make-Visible method.

    isSelected(int  index)

    Determines if a specified item in this scrolling list is selected. No error occurs if the index argument is less than 0 or greater than or equal to the number of items in this scrolling list. Returns: true if the item at the specified index has been selected; false otherwise.

    makeVisible(int  index)

    Forces the item at the specified index in this scrolling list to be visible. No error occurs if the index argument is less than 0 or greater than or equal to the number of items in this scrolling list.

    minimumSize()

    Determines the minimum size of this scrolling list. If the application has specified the number of visible rows, and that number is greater than 0, the peer's minimumSize method is called with the number of rows in order to determine the minimum size. If this scrolling list does not have a peer, or if the number of visible rows is less than or equal to zero, the superclass's minimumSize method is called to determine the minimum size. Returns: the minimum dimensions needed to display this scrolling list.

    minimumSize(int  rows)

    Determines the minimum size of a scrolling list with the specified number of rows. This scrolling lists's peer's minimumSize method is called with the number of rows in order to determine the minimum size.If this scrolling list does not have a peer the superclass's minimumSize method is called to determine the minimum size.

    Returns: the minimum dimensions needed to display the specified number of rows in a scrolling list.

    paramString()

    Returns the parameter string representing the state of this scrolling list. This string is useful for debugging. Returns: the parameter string of this scrolling list.

    preferredSize()

    Determines the preferred size of this scrolling list. If the application has specified the number of visible rows, and that number is greater than 0, the peer's preferredSize method is called with the number of rows in order to determine the preferred size. If this scrolling list does not have a peer, or if the number of visible rows is less than or equal to zero, the superclass's preferredSize method is called to determine the preferred size.>

    Returns: the preferred dimensions for displaying this scrolling list.

    preferredSize(int  rows)

    Determines the preferred size of a scrolling list with the specified number of rows. This scrolling lists's peer's preferredSize method is called with the number of rows in order to determine the preferred size. If this scrolling list does not have a peer the superclass's preferredSize method is called to determine the preferred size.

    Returns: the preferred dimensions for displaying the specified number of rows.

    removeNotify()

    Notifies this scrolling list to destroy its peer.

    replaceItem(String  newValue,                 int  index)

    Replaces the item at the given index in the scrolling list with the new string.

    select(int  index)

    Selects the item at the specified index in the scrolling list.

    setMultipleSelections(boolean  v)

    Sets whether this scolling list allows multiple selections.

    Class MediaTracker

    The MediaTracker class is a utility class to trace the status of a number of media objects. Media objects could include images as well as audio clips, though currently only images are supported. To use the media tracker, create an instance of the MediaTracker class and then call the addImage method for each image to be tracked. In addition each image can be assigned a unique identifier. The identifier controls both the priority order in which the images are fetched as well as identifying unique subsets of the images that can be waited on independently. Images with a lower ID are loaded in preference to those with a higher ID number.

    public  class  java.awt.MediaTracker extends  java.lang.Object   
    	{
    		// 	Member elements
    		public final static int ABORTED;
    		//	ABORTED = 2 :  Flag indicating the download of some media was aborted.  
    		public final static int COMPLETE;	
    		//	COMPLETE = 8  :  Flag indicating the download of media completed successfully.
    		public final static int ERRORED;	
    		//	ERRORED = 4  :  Flag indicating the download of some media encountered an error.
    		public final static int LOADING;	
    		//	LOADING = 1 :  Flag indicating some media is currently being loaded.
    		// 	Constructors 
    		public MediaTracker(Component  comp);	
    		//	Creates a media tracker to track images for a given component.
    		// 	Methods
    		public void addImage(Image  image, int  id);	 
    		public void addImage(Image  image, int  id, int w, int h);	 
    		public boolean checkAll();	
    		public boolean checkAll(boolean  load);	 
    		public boolean checkID(int  id);	
    		public boolean checkID(int  id, boolean  load);	 
    		public Object[] getErrorsAny();	 
    		public Object[] getErrorsID(int  id);	 
    		public boolean isErrorAny();	 
    		public boolean isErrorID(int  id);	 
    		public int statusAll(boolean  load); 
    		public int statusID(int  id, boolean  load);	 
    		public void waitForAll();	 
    		public boolean waitForAll(long  ms);	 
    		public void waitForID(int  id);	 
    		public boolean waitForID(int  id, long  ms);	
    	}
    
    

    Table 4.25

    Method

    Description

    addImage(Image         image, int  id)

    Adds an image to the list of images being tracked by this media tracker. The image will eventually be rendered at its default (unscaled) size.

    addImage(Image         image, int  id,      int w, int h)

    Adds an image to the list of images being tracked by this media tracker. The image will eventually be rendered at its default (unscaled) size.

    checkAll()

    Checks to see if all images being tracked by this media tracker have finished loading. This method does not start loading the images if they are not already loading. If there is an error while loading or scaling an image then that image is considered to have finished loading.Use the isErrorAny method or isErrorID method to check for errors. Returns:  true  if all images have finished loading, were aborted or encountered an error; false otherwise.

    checkAll(boolean  load)

    Checks to see if all images being tracked by this media tracker have finished loading. If the load flag is true, then start loading any images that are not yet being loaded. If there is an error while loading or scaling an image then that image is considered to have finished loading. Use the isErrorAny method or isErrorID method to check for errors. Returns : true if all images have finished loading, were aborted or encountered an error; false otherwise.

    checkID(int  id)

    Checks to see if all images tracked by this media tracker that are tagged with the specified identifier have finished loading. This method does not start loading the images if they are not already loading. If there is an error while loading or scaling an image then that image is considered to have finished loading. Use the isErrorAny method or isErrorID method to check for errors. Returns : true if all images have finished loading, were aborted or encountered an error; false otherwise.

    getErrorsAny()

    Returns: an array of media objects tracked by this media tracker that have encountered an error, or null if there are none with errors.

    getErrorsID(int  id)

    Returns:  an array of media objects tracked by this media tracker with the specified identifer that have encountered an error, or null if there are none with errors.

    isErrorAny()

    Returns : true if any of the images tracked by this media tracker had an error during loading; false otherwise.

     

     

    isErrorID(int  id)

    Checks the error status of all of the images tracked by this media tracker with the specified ID.

    Returns: true if any of the images with the specified identifier had an error during loading; false otherwise.

    statusAll(boolean                 load)

    Calculates and returns the bitwise inclusive OR of the status of all the media being tracked by this media tracker. The possible flags are specified by the following four constants :

      MediaTracker.LOADING
    
      MediaTracker.ABORTED
    
      MediatTracker.ERRORED
    
      MediaTracker.COMPLETE
      

    An image that hasn't started loading has zero as its status. If the load flag is true, then start loading any images that are not yet being loaded. Returns : the bitwise inclusive OR of the status of all of the media being tracked.

    statusID(int  id,        boolean  load)

    Calculates and returns the bitwise inclusive OR of the status of all the media tracked by this media tracker with the specified identifier. The possible flags are as above in the statusAll method. An image that hasn't started loading has zero as its status. If the load flag is true, then start loading any images that are not yet being loaded. Returns : the bitwise inclusive OR of the status of all of the media being tracked.

    waitForAll()

    Starts loading all images tracked by this media tracker. This method waits until all the images being tracked have finished loading. If there is an error while loading or scaling an image then that image is considered finished loading. Use the isErrorAny method or isErrorID method to check for errors. Throws : InterruptedException, if another thread has interrupted this thread.

    waitForAll(long  ms)

    Starts loading all images tracked by this media tracker. This method waits until all the images being tracked have finished loading, or until the length of time specified in milliseconds by the ms argument have passed. If there is an error while loading or scaling an image then that image is considered finished loading. Use the isErrorAny method or isErrorID method to check for errors.

    Returns : true if all images were successfully loaded; false otherwise.  

    Throws : InterruptedException, of another thread has interrupted this thread.

    waitForID(int  id)

    Starts loading all images tracked by this media tracker with the specified identifier. This method waits until all the images with the specified identifier have finished loading. If there is an error while loading or scaling an image then that image is considered finished loading. Use the isErrorAny method or isErrorID method to check for errors.

    Throws : InterruptedException, if another thread has interrupted this thread.

    waitForID(int  id,           long  ms)

    Starts loading all images tracked by this media tracker with the specified identifier. This method waits until all the images with the specified identifier have finished loading, or until the length of time specified in milliseconds by the ms argument have passed . If there is an error while loading or scaling an image then that image is considered finished loading. Use the isErrorAny method or isErrorID method to check for errors.

    Returns : true if all images were successfully loaded; false otherwise.

    Throws : InterruptedException, if another thread has interrupted this thread.

    Class Menu

    A menu is a pull-down component of a menu bar. A menu can optionally be a tear-off menu. A tear-off menu can remain on the screen after the mouse button has been released. The mechanism for tearing off a menu is platform dependent. Each item in a menu must belong to the MenuItem class . This can be an instance of MenuItem, a submenu (an instance of Menu), or a check box (an instance of CheckboxMenuItem).

    public class java.awt.Menu extends java.awt.MenuItem implements java.awt.MenuContainer { // Constructors public Menu(String label); public Menu(String label, boolean tearOff); // Methods public MenuItem add(MenuItem mi); public void add(String label); public void addNotify(); public void addSeparator(); public int countItems(); public MenuItem getItem(int index); public boolean isTearOff(); public void remove(int index); public void remove(MenuComponent item); public void removeNotify(); }

    Table 4.26

    Method

    Description

    add(MenuItem  mi)

    Adds the specified menu item to this menu.  If the menu item had been part of another menu, remove it from that menu. Returns :  the menu item added.

    add(String  label)

    Adds an item with the specified label to this menu. This method creates a menu item to hold the string.

    addNotify()

    This method calls the createMenu method of this object's toolkit in order to create a MenuPeer for this menu. This peer allows the application to change the look of a menu without changing its functionality. Most applications do not call this method directly.

    addSeparator()

    Adds a separator line to this menu at the current position.

    countItems()

    Returns : the number of elements in this menu.

    getItem(int  index)

    Returns :the item located at the specified index of this menu.

    isTearOff()

    Returns : true if this is a tear-off menu; false otherwise.

    remove(int  index)

    Deletes the item at the specified index from this menu.

    remove(MenuComponent  item)

    Deletes the specified menu item from this menu. If the item is not part of the menu, nothing happens.

    removeNotify()

    Notifies the menu to destroy its peer.  This menu also notifies each of its menu items to destroy their peers.

    Class MenuBar

    This class that encapsulates the platform's concept of a menu bar bound to a Frame. In order to attach the menu bar to a frame, the setMenuBar method in class Frame must be called.

    public  class  java.awt.MenuBar extends  java.awt.MenuComponent  
    	implements java.awt.MenuContainer   
    	{
    		// 	Constructors
    		public MenuBar(); 
    
    		// 	Methods
    		public Menu add(Menu  m); 
    		public void addNotify();	 
    		public int countMenus(); 
    		public Menu getHelpMenu();	 
    		public Menu getMenu(int i); 
    		public void remove(int index); 
    		public void remove(MenuComponent m); 
    		public void removeNotify();	 
    		public void setHelpMenu(Menu m); 
    	}
    
    

    Table 4.27

    Method

    Description

    add(Menu  m)

    Adds the specified menu to this menu bar.

    addNotify()

    This method calls the createMenuBar method of this object's toolkit in order to create a MenuBarPeer for this menu bar. This peer allows the application to change the look of a menu barwithout changing its functionality. Most applications do not call this method directly.

    countMenus()

    Returns :  the number of menus on this menu bar.

    getHelpMenu()

    Returns : the help menu on this menu bar.

    getMenu(int  i)

    Returns : the menu at the specified index of this menu bar

    remove(int  index)

    Removes the menu located at the specified index from this menu bar.

    remove(MenuComponent  m)

    Removes the specified menu component from this menu bar.

    removeNotify()

    Notifies this menu bar to destroy its peer.  This menu bar also notifies each of its menus to destroy their peers.

    setHelpMenu(Menu  m)

       Sets the help menu on this menu bar to be the specified menu.

    Class MenuComponent

    The abstract class MenuComponent is the superclass of all menu related components.

    public  abstract  class  java.awt.MenuComponent extends  java.lang.Object  
    	{
            // 	Constructors
        	public MenuComponent();		//	The default constructor.
            // 	Methods
        	public Font getFont();	 
        	public MenuContainer getParent();	 
        	public MenuComponentPeer getPeer();	  
        	protected String paramString();	 
        	public boolean postEvent(Event  evt);	 
        	public void removeNotify();	 
        	public void setFont(Font  f); 
        	public String toString(); 
    	}
    
    
    
    

    Table 4.28

    Method

    Description

    getFont()

    Returns : the font used in this menu component, if there is one; null otherwise.

    getParent()

    Returns :  the menu component containing this menu component; null if this is the outermost component, the menu bar itself.

    getPeer()

    Returns this menu component's peer. Every menu component has a peer associated with it. This peer allows the application to change the look of a menu component without changing its functionality. Returns : the menu component's peer.

    paramString()

    Returns the parameter string representing the state of this menu component. This string is useful for debugging. Returns : the parameter string of this menu component.

    postEvent(Event  evt)

    Posts an event to this menu component, by calling its handleEvent method. If handleEvent returns false, then post the event to the menu component's parent. Returns :true,  if this menu component or one of its parents handled the event; false otherwise.

    removeNotify()

    Notifies this menu component to destroy its peer.

    setFont(Font  f)

    Sets the font to be used for this menu component to the specified font. This font is also used by all subcomponents of the menu component, unless those subcomponents specify a different font.

    toString()

    Returns : a string representation of this menu component.

    Class MenuItem

    All items in a menu must belong to MenuItem class or a subclass. The default menu item represents a simple labeled menu item. When a menu item is selected, the AWT sends an action event to the menu item's containing frame. The event's target is the menu item, and its object is the string label of the menu item. Note that the subclass Menu overrides this behavior and does not sent any event to the frame until one of its subitems is selected.

    public  class  java.awt.MenuItem extends  java.awt.MenuComponent  
    	{
            // 	Constructors
        	public MenuItem(String  label);
    		/*	Constructs a new menu item with the specified label. The label "-" is reserved to mean a separator between menu items. By default, all menu items except for separators are enabled. 	 
    		*/
            // 	Methods
        	public void addNotify();	 
        	public void disable();	 
        	public void enable(); 
        	public void enable(boolean  cond);	 
        	public String getLabel();	 
        	public boolean isEnabled();	  
        	public String paramString();	 
        	public void setLabel(String  label);	 
    	}
    
    

    Table 4.29.

    Method

    Description

    addNotify()

    This method calls the createMenuItem method of this object's toolkit in order to create a MenuItemPeer for this menu item. This peer allows the application to change the look of a menu item,without changing its functionality. Most applications do not call this method directly.

    disable()

    Disables this menu item. It can no longer be selected by the user.

    enable()

    Enables this menu item; it can be selected by the user.

    enable(boolean  cond)

    Enables this menu item if the flag is true; otherwise, disables it.

    getLabel()

    Returns : the label of this menu item, or null if this menu item has no label.

    isEnabled()

    Checks whether this menu item is enabled. Returns : true if this menu item is enabled; false otherwise

    paramString()

    Returns the parameter string representing the state of this menu item. This string is useful for debugging.

    setLabel(String  label)

     Changes this menu item's label to be the label argument.

    Class Panel

    A Panel is the simplest container class. It provides space into which an application can attach any other component, including other panels. The AWT sends the panel all mouse, keyboard, and focus events that occur over it. The default layout manager for a Panel is the FlowLayout layout manager.

    public  class  java.awt.Panel extends  java.awt.Container   
    	{	
            	// 	Constructors
        	public Panel();	//	Creates a new panel. The default layout for a panel is FlowLayout. 	 
    
            	// 	Methods
        	public void addNotify(); 
    		/*	This method calls the createPanel method of this object's toolkit in order to create a PanelPeer for this panel. This peer allows the application to change the look of a panel without changing its functionality.
    		*/
    	}
    

    Class Point

    A point represents an (x, y) coordinate.

    public  class  java.awt.Point extends  java.lang.Object 
        			 
    	{
            // 	Member elements
        	public int x; 
        	public int y;	 
    
            // 	Constructors
        	public Point(int  x, int  y);	//	Constructs and initializes a point to the specified (x, y)  coordinate. 	  
            // 	Methods
        	public boolean equals(Object  obj); 
        	public int hashCode();	 
        	public void move(int  x, int  y);	 
        	public String toString();	 
        	public void translate(int  dx, int  dy); 
    	}
    
    

    Table 4.30

    Method

    Description

    equals(Object  obj)

    The result is true if and only if the argument is not null and is a Point object that has the same x and y coordinates as this object. Returns :  true if the objects are the same; false otherwise.

    hashCode()

    Returns : a hash code value for this point.

    move(int  x, int  y)

    Modifies this point so that it now represents the (x, y )   coordinates indicated.

    toString()

    Returns :  a string representation of this point.

    translate(int  dx, int  dy)

    Translates this point by dx to the right and dy downward so that it now represents the point (x +dx, y + dy) , where it had been representing the point (x, y).

    Class Polygon

    A polygon consists of a list of (x, y ), where each successive pair of coordinates defines a side of the polygon.

    public  class  java.awt.Polygon extends  java.lang.Object  
    	{
    		// 	Member elements
    		public int npoints;	 	//	The total number of points.
    		public int xpoints[];	//	The array of  x coordinates. 	 
    		public int ypoints[]; 	//	The array of  y coordinates.
    		// 	Constructors
    		public Polygon();	//	Creates an empty polygon. 	 
    		public Polygon(int  xpoints[], int  ypoints[], int  npoints);
    		//	Constructs and initializes a polygon from the specified parameters.
    		// 	Methods
    		public void addPoint(int  x, int  y);	
    		/*	Appends a point to this polygon. If an operation that calculates the bounding box of this polygon (getBoundingBox  or inside) has already been performed, this method updates the bounding box.
    		*/ 
    		public Rectangle getBoundingBox();	//	Returns : the smallest rectangle that contains this polygon. 	 
    		public boolean inside(int  x, int  y);
    		/*	Determines if the specified point is inside this polygon. This method uses an even-odd insideness rule (also known as an "alternating rule") to determine whether the pont (x, y) inside this polygon. 
    			Returns : true if the point ( x, y) is inside this polygon; false otherwise.
    		*/  	 
    	} 
    

    Class Rectangle

    A rectangle specifies an area defined by its top-left (x, y) coordinate, its width and its height.

    	public  class  java.awt.Rectangle extends  java.lang.Object 
        			 
    	{
    		// 	Member elements
    		public int height;	 	//	The height of the rectangle.
    		public int width;		//	The width of the rectangle. 	 
    		public int x;		//	The x coordinate of the top left corner of the rectangle. 
    		public int y;		//	The y coordinate of the top left corner of the rectangle.
    		 // 	Constructors
    		public Rectangle();	
    		//Constructs a new rectangle whose top-left corner is (0, 0), and whose width and height are 0. 
    		public Rectangle(Dimension  d);	 
    		/*	Constructs a new rectangle whose top-left corner is  (0, 0) and whose width and height are specified by the dimension argument.
    		*/
    		public Rectangle(int  width, int  height);
    		//	Constructs a new rectangle whose top-left corner is  (0, 0), and whose width and height are the specified arguments 	 
    		public Rectangle(int  x, int  y, int  width, int height);
    		//	Constructs a new rectangle whose top-left corner is (x, y), and whose width and height are the specified arguments. 
    		public Rectangle(Point  p);
    		//	Constructs a new rectangle whose top-left corner is the specified point argument and whose width and height are 0. 	 
    		public Rectangle(Point  p, Dimension  d);
    		/*	Constructs a new rectangle whose top-left corner is the specified point argument and and whose width and height are specified by the dimension argument. 	 
    		*/
    		// 	Methods
    		public void add(int  newx, int  newy);	 
    		public void add(Point  pt);	 
    		public void add(Rectangle  r);	 
    		public boolean equals(Object  obj);	 
    		public void grow(int  h, int  v);	 
    		public int hashCode();	 
    		public boolean inside(int  x, int  y);	 
    		public Rectangle intersection(Rectangle  r); 
    		public boolean intersects(Rectangle  r); 
    		public boolean isEmpty();	 
    		public void move(int  x, int  y); 
    		public void reshape(int  x, int  y, int  width, int height); 
    		public void resize(int  width, int  height);	 
    		public String toString();	 
    		public void translate(int  dx, int  dy);	 
    		public Rectangle union(Rectangle  r);	 
    	}
    
    

    Table 4.31

    Method

    Description

    add(int  newx, int  newy)

    Adds the point (newx, newy) to this rectangle. This rectangle is modified to be the smallest rectangle that contains both this rectangle and the point.

    add(Point  pt)

    Adds the point to this rectangle.  This rectangle is modified to be the smallest rectangle that contains both this rectangle and the point.

    add(Rectangle  r)

    Adds the rectangle argument to this rectangle.  This rectangle is modified to be the smallest rectangle that contains both rectangles.

    equals(Object  obj)

    The result is true if and only if the argument is not null and is a Rectangle object that has the same top-left corner, width, and height as this object. Returns: true if the objects are the same; false otherwise.

    grow(int  h, int  v)

    Modifies the rectangle so that it is h units larger on both the left and right size, and v units larger at both the top and bottom The new rectangle has (x-h, y-v) as its top-left corner, a width of (x +2h)and a height of (y + 2v):p>

    hashCode()

    Returns: a hash code value for this object.

    inside(int  x, int  y)

    Checks if the specified point lies inside this rectangle. Returns: true if the point (x, y) is inside this rectangle; false otherwise.

    intersection(Rectangle  r)

    Returns: the largest rectangle contained in both the rectangle argument and in this rectangle.

    intersects(Rectangle  r)

    Determines if this rectangle and the rectangle argument intersect. Two rectangles insersect if their intersection is non-empty. Returns: true if the rectangle argument and this rectangle insersect; false otherwise.

    isEmpty()

    Determines if this rectangle is empty. A rectangle is empty if its width or its height is less than or equal to zero. Returns:  true if this rectangle is empty; false otherwise.

    move(int  x, int  y)

    Moves this rectangle so that its new top-left corner is the specified (x, y)coordinate.

    reshape( ... )

    Reshapes this rectangle so that its new top-left corner is the specified (x, y) coordinate and its new width and height are the specified arguments.

    resize( .... )

    Resizes this rectangle so that its new width and height are the indicated arguments.

    toString()

    Returns: a string representation of this rectangle.

    translate(int  dx, int  dy)

    Translates this rectangle by dx to the right and dy downward so that its top- left corner is now point (x + dx, y + dy),where it had been the point (x, y).

    union(Rectangle  r)

    Computes the union of this rectangle with the argument rectangle. Returns:  the smallest rectangle containing both the rectangle argument and this rectangle.

    Class Scrollbar

    A scroll bar provides a convenient means of allowing a user to select from a range of values. Alternatively, a scroll bar can represent a range of values.

    public  class  java.awt.Scrollbar extends  java.awt.Component
        			  
    	{
    		// 	Member elements
    		public final static int HORIZONTAL;	//	Constant indicating to construct a horizontal scroll bar. 	 
    		public final static int VERTICAL;	//	Constant indicating to construct a vertical scroll bar. 
    		// 	Constructors 
    		public Scrollbar();				//	Constructs a new vertical scroll bar. 
    		public Scrollbar(int  orientation);	
    		/*	Constructs a new scroll bar with the specified orientation.The orientation argument must be one of the two values Scrollbar.HORIZONTAL  Scrollbar.VERTICAL   indicating a horizontal or vertical scroll bar, respectively. Throws : IllegalArgumentException  , when an illegal orientation is given.
    		*/
    		public Scrollbar(int  orientation, int  value, int  visible,int  minimum, int  maximum);
    		/*	Constructs a new scroll bar with the specified orientation, initial value, page size, and minumum and maximum values. The orientation argument must be one of the two values Scrollbar.HORIZONTAL  Scrollbar.VERTICAL   indicating a horizontal or vertical scroll bar, respectively. If the specified maximum value is less than the minimum value, it is changed to be the same as the minimum value. If the initial value is lower than the minimum value, it is changed to be the minimum value; if it is greater than the maximum value, it is changed to be the maximum value.
    		*/
    		// 	Methods
    		public void addNotify();	 
    		public int getLineIncrement(); 
    		public int getMaximum(); 
    		public int getMinimum();	 
    		public int getOrientation();	 
    		public int getPageIncrement();	 
    		public int getValue(); 
    		public int getVisible();	 
    		protected String paramString();	 
    		public void setLineIncrement(int  l);	 
    		public void setPageIncrement(int  l); 
    		public void setValue(int  value);	 
    		public void setValues(int value, int visible, int  minimum, int  maximum);
    	}
    
    

    Table 4.32

    Method

    Description

    addNotify

    This method calls the createScrollbar method of this object's toolkit in order to create a ScrollbarPeer for this button. This peer allows the application to change the look of a scroll bar without changing its functionality. Most applications do not call this method directly.

    getLineIncrement()

    Determines the line increment of this scrollbar, which is the amount that is added or subtracted from this scroll bar's value when the user hits the down or up gadget. Returns: the line increment of this scroll bar.

    getMaximum()

    Returns: the maximum value of this scroll bar.

    getMinimum()

    Returns:  the maximum value of this scroll bar.

    getOrientation()

    Determines the orientation of this scroll bar. The value returned is either HORIZONTAL or VERTICAL. Returns: the orientation of this scroll bar.

    getPageIncrement()

    Determines the page increment of this scroll bar, which is the amount that is added to or subtracted from this scroll bar' value when the user hits the page down or page up gadget.  Returns: the page increment for this scroll bar.

    getValue()

    Returns: the current value of this scroll bar.

    getVisible()

    Determines the "visible" amount of this scroll bar, which is the range of values represented by the width of the bubble in this scroll bar. Returns:  the "visible" amount of this scroll bar.

    paramString()

    Returns the parameter string representing the state of this scroll bar. This string is useful for debugging. Returns:  the parameter string of this scroll bar.

    setLineIncrement(int  l)

    Sets the line increment of this scroll bar.      The line increment is the value that is added to or subtracted from the value of this scroll bar when the user hits the line down or line up gadget.

    setPageIncrement(int  l)

    Sets the page increment of this scroll bar.   The page increment is the value that is added to or subtracted from the value of the scroll bar when the user hits the page down or page up gadget.

    setValue(int  value)

    Sets the value of this scroll bar to the specified value. If the specified value is below this scroll bar's current minimum or above the current maximum, it becomes the minimum or maximum value, respectively.

    setValues(int value,..)

       Sets several parameters of this scroll bar simultaneously.

    Class TextArea

    A text area is a multiline area for displaying text. It can be set to allow editing or to be read-only.

    public  class  java.awt.TextArea extends  java.awt.TextComponent  
    	{
    		// 	Constructors
    		public TextArea();			//	Constructs a new text area. 	 
    		public TextArea(int  rows, int  cols);	
    		//	Constructs a new text area with the specified number of rows and columns.
    
    		public TextArea(String  text);	//	Constructs a new text area with the specified text displayed.
    	 
    		public TextArea(String  text, int  rows, int cols); 
    		//	Constructs a new TextArea with the specified text, and the specified number of rows and columns.
    		// 	Methods
    		public void addNotify();	 
    		public void appendText(String  str);	 
    		public int getColumns();	
    		public int getRows(); 
    		public void insertText(String  str, int  pos);	 
    		public Dimension minimumSize(); 
    		public Dimension minimumSize(int  rows, int  cols); 
    		protected String paramString();	 
    		public Dimension preferredSize();	 
    		public Dimension preferredSize(int  rows, int  cols);	 
    		public void replaceText(String  str, int  start, int  end);	 
    	}
    
    

    Table 4.33

    Method  

    Description

    addNotify()

    This method calls the createTextArea method of this object's toolkit in order to create a TextAreaPeer for this text area. This peer allows the application to change the look of a text area without changing its functionality. Most applications do not call this method directly.p>

    appendText(String  str)

    Appends the given text to this text area's current text.

    getColumns()

    Returns: the number of columns in this text area.

    getRows()

    Returns: the number of rows in this text area.

    insertText(String str, int pos)

    Inserts the specified text at the specified position in this text area.

    minimumSize()

    Determines the minimum size of this text area. If the application has specified both the number of rows and the number of columns for this text area, and both are greater than zero, then the text area's peer's minimumSize method is called with the number of rows and columns in order to determine the minimum size. If the text area does not have a peer, or if the number of rows or number of columns specified by the application is less than or equal to zero, the superclass's minimumSize method is called to determine the minimum size. Returns: the minimum dimensions needed for this text area.

    minimumSize(int rows, int  cols)

    Determines the minimum size of a text area with the specified number of rows and columns. This text area's peer's minimumSize method is called with the number of rows and columns in order to determine the minimum size. If this text area does not have a peer, the superclass's minimumSize method is called to determine the minimum size. Returns: the minimum dimensions needed to display the text area with the specified number of rows and columns.

    paramString()

    Returns the parameter string representing the state of this text area. This string is useful for debugging. Returns:  the parameter string of this text area.

    preferredSize()

    Determines the preferred size of this text area. If the application has specified both the number of rows and the number of columns for this text area, and both are greater than zero, then the text area's peer's preferredSize method is called with the number of rows and columns in order to determine the preferred size. If this text area does not have a peer, or if the number of rows or number of columns specified by the application is less than or equal to zero, the superclass's preferredSize method is called to determine the preferred size. Returns: the preferred dimensions needed for this text area.

    preferredSize(int rows, int  cols)

    Determines the preferred size of a text area with the specified number of rows and columns. This text area's peer's preferredSize method is called with the number of rows and columns in order to determine the preferred size. If this text area does not have a peer the superclass's preferredSize method is called to determine the preferred size. Returns: the preferred dimensions needed to display the text area with the specified number of rows and columns.

    replaceText(String  str, int               start, int  end)

    Replaces the text in the text area from the start (inclusive) index to the end (exclusive) index with the new text specified.

    Class TextComponent

    A text component is the superclass of any component that allows the editing of some text.

    public  class  java.awt.TextComponent extends  java.awt.Component
        			   
    	{
    
            // 	Methods
        	public String getSelectedText();	 
        	public int getSelectionEnd();	 
        	public int getSelectionStart();	 
        	public String getText();	 
        	public boolean isEditable();	 
        	protected String paramString();	 
        	public void removeNotify();	 
        	public void select(int  selStart, int  selEnd); 
        	public void selectAll();	 
        	public void setEditable(boolean  t); 
        	public void setText(String  t);	 
    	} 
    
    

    Table 4.34

    Method

    Description

    getSelectedText()

    Returns: the selected text in this text component.

    getSelectionEnd()

    Returns: selected text's end position in this text component.

    getSelectionStart()

    Returns:  the selected text's start position in this text component.

    getText()

    Returns: the text of this text component.

    isEditable()

    Returns:  true if this text component is editable; false otherwise.

    paramString()

    Returns the parameter string representing the state of this text component. This string is useful for debugging.  Returns: the parameter string of this text component.

    removeNotify()

    Notifies this text component to destroy its peer.

    select(int selStart, int selEnd)

    Selects the text in this text component found from the specified start (inclusive) index to the specified end index (exclusive).

    selectAll()

    Selects all the text in this text component.

    setEditable(boolean  t)

    If the boolean argument is true, this text component becomes user editable. If the flag is false, the user cannot change the text of this text component.

    setText(String  t)

    Sets the text of this text component to be the specified text.

    Class TextField

    A text field is a component that presents the user with a single editable line of text.

    public  class  java.awt.TextField extends  java.awt.TextComponent
        				  
    	{
    		// 	Constructors 
    		public TextField();			//	Constructs a new text field. 
    		public TextField(int  cols);  	//	Constructs a new text field the specified number of characters wide.
    		public TextField(String  text); 	//	Constructs a new text field initialized with the specified text.
    		public TextField(String  text, int  cols);
    		/*	Constructs a new text field initialized with the specified text and wide enough to hold the specified number of characters. 	 
    		*/
    		// 	Methods
    		public void addNotify();	 
    		public boolean echoCharIsSet();	 
    		public int getColumns();	 
    		public char getEchoChar();	 
    		public Dimension minimumSize(); 
    		public Dimension minimumSize(int  cols);	 
    		protected String paramString();	 
    		public Dimension preferredSize();	 
    		public Dimension preferredSize(int  cols);	 
    		public void setEchoCharacter(char  c);	 
    	}
    
    

    Table 4.35

    Method

    Description

    addNotify()

    This method calls the createTextField method of this object's toolkit in order to create a TextFieldPeer for this text field. This peer allows the application to change the look of a text field without changing its functionality. Most applications do not call this method directly.

    echoCharIsSet()

    Returns : true if this text field has a character set for echoing; false otherwise.

    getColumns()

    Returns :  the number of columns in this text field.

    getEchoChar()

    Returns : the echo character for this text field.

    minimumSize()

    Determines the minimum size of this text field. If the application has specified the number of columns for this text field, and it is greater than zero, then this text field's peer's minimumSize method is called with the number columns in order to determine the minimum size. If this text field does not have a peer, or if the number of columns specified by the application is less than or equal to zero, the superclass's minimumSize method is called to determine the minimum size

    minimumSize(int  cols)

    Determines the minimum size of a text field with the specified number of columns. This text field's peer's minimumSize method is called with the number of columns in order to determine the minimum size. If this text field does not have a peer the superclass's minimumSize method is called to determine the minimum size.

    paramString()

    Returns the parameter string representing the state of this text field. This string is useful for debugging.

    preferredSize()

    Determines the preferred size of this text field. If the application has specified the number of columns for this text field, and it is greater than zero, then this text field's peer's preferredSize method is called with the number of columns in order to determine the preferred size

    preferredSize(int  cols)

    Determines the preferred size of a text field with the specified number of columns. This text field's peer's preferredSize method is called with the number columns in order to determine the preferred size.

    setEchoCharacter(char  c)

    Sets the echo character for this text field. Any character that the user types in the text field is echoed in this text field as the echo character. An echo character is useful for fields where the user input shouldn't be echoed to the screen such as in the case of a text field for typing in a password.

    Class Toolkit

    This class is the abstract superclass of all actual implementations of the Abstract Window Toolkit. Subclasses of the class are used to bind the various components to particular native toolkit implementations. Most applications should not call any of the methods is this class directly. These methods are called by the addNotify methods of the various components in the Abstract Window Toolkit.

    public  abstract  class  java.awt.Toolkit extends  java.lang.Object  
    	{
    		// 	Constructors
    		public Toolkit();
    		//	The default constructor for a toolkit. 	
    		// 	Methods
    		public abstract int checkImage(Image  image, int  width, int height, ImageObserver  observer);
    		protected abstract ButtonPeer createButton(Button  target);
    		protected abstract CanvasPeer createCanvas(Canvas  target);
    		protected abstract CheckboxPeer createCheckbox(Checkbox  target);
    		protected abstract CheckboxMenuItemPeer  createCheckboxMenuItem (CheckboxMenuItem  target);
    		protected abstract ChoicePeer createChoice(Choice  target);
    		protected abstract DialogPeer createDialog(Dialog  target);
    		protected abstract FileDialogPeer createFileDialog(FileDialog  target);
    		protected abstract FramePeer createFrame(Frame  target);	
    		public abstract Image createImage(ImageProducer  producer);
    		protected abstract LabelPeer createLabel(Label  target); 
    		protected abstract ListPeer createList(List  target);	
    		protected abstract MenuPeer createMenu(Menu  target); 
    		protected abstract MenuBarPeer createMenuBar(MenuBar  target);
    		protected abstract MenuItemPeer createMenuItem(MenuItem  target);
    		protected abstract PanelPeer createPanel(Panel  target); 
    		protected abstract ScrollbarPeer createScrollbar(Scrollbar  target);
    		protected abstract TextAreaPeer	createTextArea(TextArea  target);
    		protected abstract TextFieldPeer createTextField(TextField  target);
    		protected abstract WindowPeer  createWindow(Window  target);
    		public abstract ColorModel getColorModel(); 
    		public static Toolkit getDefaultToolkit();	 
    		public abstract String[] getFontList(); 
    		public abstract FontMetrics getFontMetrics(Font  font);
    		public abstract Image getImage(String  filename);	 
    		public abstract Image getImage(URL  url);	 
    		public abstract int getScreenResolution(); 
    		public abstract Dimension getScreenSize();	 
    		public abstract boolean prepareImage(Image  image, int  width, int  height, ImageObserver  observer);
    		public abstract void sync(); 
    	}
                               
                                   
    
    

    Table 4.36 

    Method

    Description

    checkImage( ... )

    If the width and height arguments are both -1, this method returns the status of the construction of a screen representaion of the specified image in this toolkit. Otherwise, this method returns the status of the construction of a scaled representation of the specified image at the specified width and height. This method does not cause the image to begin loading. An application must use the prepareImage method to force the loading of an image. This toolkit method is used by the checkImage methods of Component. Information on the flags returned by this method can be found in. Returns: the bitwise inclusive OR of the ImageObserver flags indicating what information about the image is available.

    createButton(Button  target)                                    

    Returns: this toolkit's implementation of a Button.

    createCanvas(Canvas  target)

    Returns: this toolkit's implementation of a Canvas.

    createCheckbox(Checkbox  target)

    Returns: this toolkit's implementation of a Checkbox.

    createCheckboxMenuItem( ... )

    Returns: this toolkit's implementation of a CheckboxMenuItem.

    createChoice(Choice  target)

    Returns: this toolkit's implementation of a Choice.

    createDialog(Dialog  target)

    Returns: this toolkit's implementation of a Dialog.

    createFileDialog(FileDialog  target)

    Returns:  this toolkit's implementation of a FileDialog .

    createFrame(Frame  target)

    Returns: this toolkit's implementation of a Frame

    createImage(ImageProducer  producer)

    Returns: this toolkit's implementation of an Image.

    createLabel(Label  target)

    Returns: this toolkit's implementation of a Label.

    createList(List  target)

    Returns: this toolkit's implementation of a List.

    createMenu(Menu  target)

    Returns:  this toolkit's implementation of a Menu.

    createMenuBar(MenuBar  target)

    Returns:  this toolkit's implementation of a MenuBar

    createMenuItem(MenuItem  target)

    Returns:  this toolkit's implementation of a MenuItem .

    createPanel(Panel  target)

    Returns: this toolkit's  implementation of a Panel.

    createScrollbar(Scrollbar  target)

    Returns: this toolkit's implementation of a ScrollBar .

    createTextArea(TextArea  target)

    Returns: this toolkit's implementation of a TextArea.

    createTextField(TextField  target)

    Returns: this toolkit's implementation of a TextField.

    createWindow(Window  target)

    Returns: this toolkit's implementation of a Window.

    getColorModel()

    Determine's the color model of this toolkit's screen. The ColorMod is an abstract class that encapsulates how to translate between pixel values of an image and its red, green, blue, and alpha components. This toolkit method is used by the getColorModel method of Component.

    getDefaultToolkit()

    Gets the default toolkit.  If there is a system property named "awt.toolkit", that property is treated as the name of a class that is a subclass of Toolkit. If the system property does not exist, then the default toolkit used is the class named "sun.awt.motif.MToolkit", which is a motif implementation of the Abstract Window Toolkit. Returns: the default toolkit.Throws :AWTError, if a toolkit could not be found or could not be instantiated.

    getFontList()

    Returns: the names of the available fonts in this toolkit.

    getFontMetrics(Font  font)

    Returns:  the screen metrics of the font argument in this toolkit.

    getImage(String  filename)

    Returns: an image which gets its pixel data from the specified file

    getImage(URL  url)

    Returns: an image which gets its pixel data from the specified URL.

    getScreenResolution()

    Returns:  this toolkit's screen resolution in dots-per-inch.

    getScreenSize()

    Returns: the size of this toolkit's screen in pixels.

    prepareImage( ... )

    Prepares an image for rendering. If the width and height arguments are both -1, this method prepares the image for rendering on the default screen; otherwise, this method prepares an image for rendering on the default screen at the specified width and height. The image data is downloaded asynchronously in another thread and an appropriately scaled screen representation of the image is generated. This toolkit method is used by the prepareImage methods of Component. Information on the flags returned by this method can be found in. Returns:true if the image has already been fully prepared; false otherwise

    sync()                                

    Synchronizes this toolkit's graphics state. Some window systems may do buffering of graphics events. This method ensures that the display is up to date.

    Class Window

    A Window is a top-level window; it has no borders and no menubar. It could be used, for example, to implement a pop-up menu. The AWT sends the window all mouse, keyboard, and focus events that occur over it. The default layout for a window is BorderLayout.

    public  class  java.awt.Window extends  java.awt.Container
        				  
    	{
            // 	Constructors
        	public Window(Frame  parent);	
    		/*	Constructs a new invisible window. The window behaves as a modal dialog in that it will block input to other application windows when shown. Use the show method to cause the window to become visible. 
    		*/
            // 	Methods
        	public void addNotify();	 
        	public void dispose();	 
        	public Toolkit getToolkit();	 
        	public final String getWarningString(); 
        	public void pack();	 
        	public void show(); 
        	public void toBack();	 
        	public void toFront();	 
    	}
    
    

    Table 4.37

    Method  

    Description

    addNotify()

    This method calls the createWindow method of this object's toolkit in order to create a WindowPeer for this window. This peer allows the application to change the look of a window without changing its functionality. Most applications do not call this method directly.

    dispose()

    Disposes of this window and any resources used by this window.

    getToolkit()

    Determines the toolkit of this window. The implementation of getToolkit in class Window returns the default toolkit . However subclasses of Window can override this method in order to create their own toolkits. Returns: the toolkit of this window.

    getWarningString()

    Returns the warning string that is displayed with this window. If this window is insecure, the warning string is displayed somewhere in the visible area of the window. A window is insecure if there is a security manager, and its checkTopLevelWindow method returns false when passed this window as an argument. If the window is secure, then the getWarningString method returns null. If the window is insecure, this methods checks for a system property awt.appletWarning and returns the string value of that property. If there is no such property, the default warning string is used instead. The default warning string is "Warning: Applet Window". Returns: the warning string for this wind

    pack()

    Causes the subcomponents of this window to be laid out at their preferred size.

    show()

    If this window is not yet visible, make it visible. If this window is already visible, then bring it to the front.

    toBack()

    Sends this window to the back.

    toFront()

    Brings this window to the front.

    Interface LayoutManager

    The LayoutManager interface specifies the methods that all layout managers must implement. Alayout manager is a class for laying out the components of a Container.

    public  interface  java.awt.LayoutManager
    	{
            // 	Methods
        	public abstract void addLayoutComponent(String name, Component comp);
        	public abstract void layoutContainer(Container parent); 
    		public abstract Dimension minimumLayoutSize(Container parent);
        	public abstract Dimension preferredLayoutSize(Container parent);
        	public abstract void removeLayoutComponent(Component comp);
    	}
    
    

    Table 4.38 

    Method

    Description

    addLayoutComponent( ... )

          Adds the specified component to this layout using the                     indicated tag.  Most    applications          do not call this                method directly. This method is called when a component is        added to a  container using the add(String,  Component) method.  

    layoutContainer( ... )    

    Lays out the container argument using this layout.  This method may reshape the components in the specified target container in order to satisfy the constraints of this layout manager.  Most applications do not call this method directly. This method is called when a container calls its layout method.

    minimumLayoutSize( ... )

    Determines the minimum size of the container argument using this layout manager. Most applications do not call this method directly. This method is called when a container calls its layout method. Returns: the minimum dimensions needed to lay out the subcomponents of the specified container.

    preferredLayoutSize( ... )

    Determines the preferred size of the container argument using this layout manager. Most applications do not call this method directly. This method is called when a container calls its preferredSize method.Returns: the preferred dimensions to lay out the subcomponents of the specified container.

    removeLayoutComponent( ...)

    Removes the specified component from this layout.Most applications do not call this method directly. This method is called when a container calls its remove or removeAll methods.

    Interface MenuContainer

    The MenuContainer interface specifies the methods that all menu-related containers must implement. Note that menu containers are not required to be full-fleged Container objects.

    public  interface  java.awt.MenuContainer
    	{
            // 	Methods
        	public abstract Font getFont();	
    		public abstract boolean postEvent(Event  evt); 
        	public abstract void remove(MenuComponent  comp);	 
    	}
    
    

             

    Table 4.39

    Method

    Description

    getFont()

    Returns: the font used in this menu component, if there is one; null otherwise .

    postEvent(Event  evt)

    Posts an event to this menu container. eturns: true if this menu component or one of its parents handled the event; false otherwise.

    remove(MenuComponent  comp)

    Removes the specified menu component from this menu container.

    Class AWTException

    Thrown when an Abstract Window Toolkit exception has occurred.

    public  class  java.awt.AWTException extends java.lang.Exception  
        			
    	{
            // 	Constructors
        	public AWTException(String  msg);	//	Constructs an AWTException with the specified detail message. 	 
    	}
    
    

    Class AWTError

    public  class  java.awt.AWTError extends  java.lang.Error
        			  
    	{
            	// 	Constructors
        	public AWTError(String  msg);	//	Constructs an AWTException with the specified detail message. 	 
    	}