EarthWeb sites:
|
|
appendix F
java.awt
Package Reference
CONTENTS
The java.awt package contains
what is known as the Java Abstract Windowing Toolkit. The classes
within this package make up the prebuilt graphical user interface
components that are available to Java developers through the Java
Developer's Kit. Classes defined within this package include such
useful components as colors, fonts, and widgets such as buttons
and scrollbars.
The LayoutManager interface
is provided so that it can be implemented by objects that know
how to lay out containers.
addLayoutComponent
void addLayoutComponent(String name,
Component comp)
The addLayoutComponent
method lays out the specified component within the layout manager.
Parameters:
name-the name of
the component to be laid out.
comp-the Component
object to be laid out within the layout manager.
removeLayoutComponent
void removeLayoutComponent(Component
comp)
The removeLayoutComponent
method removes a specified component from the layout manager.
Parameters: comp-the
Component object that is
to be removed from within the layout manager.
preferredLayoutSize
Dimension preferredLayoutSize(Container
parent)
The preferredLayoutSize
method determines the preferred layout size for a specified container.
Parameters: parent-a
Container object that is
to be laid out using the layout manager.
Returns: A Dimension
object containing the preferred size of the Container
parameter.
minimumLayoutSize
Dimension minimumLayoutSize(Container
parent)
The minimumLayoutSize
method determines the minimum layout size for a specified container.
Parameters: parent-a
Container object that is
to be laid out using the layout manager.
Returns: A Dimension
object containing the minimum size of the Container
parameter.
layoutContainer
void layoutContainer(Container parent)
The layoutContainer
method will lay out the specified Container
object within the layout manager.
Parameters: parent-a
Container object that is
to be laid out using the layout manager.
The MenuContainer is an interface
that is implemented by all menu-related containers.
getFont
Font getFont()
The getFont method
returns the current font of the menu container.
Returns: The current Font
object.
postEvent
boolean postEvent(Event evt)
The postEvent
method posts the specified event to the MenuContainer.
Parameters: evt-the
Event object to be posted
to the menu container.
Returns: A boolean value containing true
if the event was handled, false
if not.
remove
void remove(MenuComponent comp)
The remove method
removes the specified MenuComponent
object from the MenuContainer.
Parameters: comp-the
MenuComponent class to be
removed from the MenuContainer.
Extends: Object
Implements: LayoutManager
A BorderLayout
is used to lay out components on a panel by implementing the LayoutManager
interface. Components are laid out using members named North,
South, East,
West, and Center.
BorderLayout Constructor
public BorderLayout()
This BorderLayout
constructor constructs a BorderLayout
layout manager.
BorderLayout Constructor
public BorderLayout(int hgap, int vgap)
This BorderLayout
constructor constructs a BorderLayout
layout manager using the hgap
and vgap values to set the
horizontal and vertical gap sizes.
Parameters:
hgap-an integer value
used to set the horizontal gap size.
vgap-an integer value used
to set the vertical gap size.
addLayoutComponent
public void addLayoutComponent(String
name, Component comp)
addLayoutComponent adds a component to the border
layout according to that component's name (North,
South, East,
West, or Center).
The component's preferred size is used for all layout types except
Center.
Parameters:
name-a string value
that must correspond to one of the following names: North,
South, East,
West, or Center.
comp-a Component
object to be added to this layout manager.
removeLayoutComponent
public void removeLayoutComponent(Component
comp)
removeLayoutComponent removes the specified component
from the layout manager.
Parameters: comp-the
Component object to be removed
minimumLayoutSize
public Dimension minimumLayoutSize(Container
target)
minimumLayoutSize returns the minimum dimension needed
to lay out the components contained in the target
parameter. Note that this function only determines the required
size based on visible components.
Parameters: target-a
Container class containing
components to be laid out.
preferredLayoutSize
public Dimension preferredLayoutSize(Container
target)
preferredLayoutSize returns the preferred dimension
needed to lay out the components contained in the target
parameter. This dimension is based on the individual component's
preferred sizes. Note that this function only determines the required
size based on visible components.
Parameters: target-a
Container class containing
components to be laid out.
layoutContainer
public void layoutContainer(Container
target)
layoutContainer will lay out the components contained
in the target Container
parameter. This method will reshape the components in the container
based on the requirements of the border layout itself.
Parameters: target-a
Container class containing
components to be laid out.
toString
public String toString()
toString returns a string representation of the BorderLayout
class.
Returns: A String
value containing the BorderLayout
class's name plus its hgap
and vgap values.
Extends: Component
A button can be placed on any type of layout because
it derives directly from Component.
Button Constructor
public Button()
This BUTTON constructor
constructs a simple button with no text label.
Button Constructor
public Button(String label)
This Button constructor
constructs a simple button with a text label.
Parameters: label-a
String value used to set
the button's label.
addNotify
public synchronized void addNotify()
addNotify sets the peer of the button using the function
getToolkit.createButton.
Using peer interfaces allows the user interface of the button
to be changed without changing its functionality.
getLabel
public String getLabel()
getLabel returns the button's label string.
Returns: A String
value representing the button's label string.
setLabel
public void setLabel(String label)
setLabel modifies the button's label string.
Parameters: label-a
String value representing
the button's new label string.
Extends: Component
A Canvas is used as a drawing surface for GUI applications.
addNotify
public synchronized void addNotify()
addNotify sets the peer of the canvas using the function
getToolkit.createCanvas.
Using peer interfaces allows the user interface of the canvas
to be changed without changing its functionality.
paint
public void paint(Graphics g)
The paint method
paints the canvas using the default background color (determine
by calling getBackground).
Extends: Object
Implements: LayoutManager
The CardLayout class is a
layout manager that allows the addition of "cards,"
only one of which may be visible at any given time. The user can
"flip" through the cards.
CardLayout Constructor
public CardLayout()
This CardLayout
constructor creates a new CardLayout
layout manager.
CardLayout Constructor
public CardLayout(int hgap, int vgap)
This CardLayout
constructor constructs a CardLayout
layout manager using the hgap
and vgap values to set the
horizontal and vertical gap sizes.
Parameters:
hgap-an integer value
used to set the horizontal gap size.
vgap-an integer value used
to set the vertical gap size.
addLayoutComponent
public void addLayoutComponent(String
name, Component comp)
addLayoutComponent adds a component to the card layout.
Parameters:
name-a string value that
corresponds to the component's name.
comp-a Component
object to be added to this layout manager.
removeLayoutComponent
public void removeLayoutComponent(Component
comp)
removeLayoutComponent removes the specified component
from the layout manager.
Parameters: comp-the
Component object to be removed.
minimumLayoutSize
public Dimension minimumLayoutSize(Container
target)
minimumLayoutSize returns the minimum dimension needed
to lay out the components contained in the target
parameter. Note that this function only determines the required
size based on visible components.
Parameters: target-a
Container class containing
components to be laid out.
preferredLayoutSize
public Dimension preferredLayoutSize(Container
target)
preferredLayoutSize returns the preferred dimension
needed to lay out the components contained in the target
parameter. This dimension is based on the individual component's
preferred sizes. Note that this function only determines the required
size based on visible components.
Parameters: target-a
Container class containing
components to be laid out.
LayoutContainer
public void layoutContainer(Container parent)
layoutContainer will lay out the components contained
in the target Container
parameter. This method will reshape the components in the container
based on the requirements of the border layout itself.
Parameters: target-a
Container class containing
components to be laid out.
first
public void first(Container parent)
The first method
shows the first component in the card layout (the first card).
Parameters: parent-the
parent Container class containing
the components to be flipped through.
next
public void next(Container parent)
The next method
shows the next component in the card layout (the next card).
Parameters: parent-the
parent Container class containing
the components to be flipped through.
previous
public void previous (Container parent)
The previous
method shows the previous component in the card layout (the previous
card).
Parameters: parent-the
parent Container class containing
the components to be flipped through.
last
public void last(Container parent)
The last method
shows the last component in the card layout (the last card).
Parameters: parent-the
parent Container class containing
the components to be flipped through.
show
public void show(Container parent, String
name)
The show method
flips to the component specified in the name
parameter.
Parameters:
parent-the parent
Container class containing
the components to be flipped through.
name-a string value representing
the name of the component to be displayed.
toString
public String toString()
toString returns a string representation of the card
layout class.
Returns: A String
value containing the card layout class's name plus its hgap
and vgap values.
Extends: Component
A Checkbox is
a user interface component that is used to represent a true/false
(or on/off)
value.
Checkbox Constructor
public Checkbox()
This Checkbox
constructor constructs the simplest of all check boxes: one with
no label, no group, and a false
state value.
Checkbox Constructor
public Checkbox(String label)
This Checkbox
constructor constructs a check box using the label
parameter to set the check box's label. This check box will belong
to no group and will be set to a false
state value.
Parameters: label-a
string value representing the check box's label.
Checkbox Constructor
public Checkbox(String label, CheckboxGroup
group, boolean state)
This Checkbox
constructor constructs a check box including the label, group,
and initial value.
Parameters:
label-a string value representing
the check box's label.
group-a CheckboxGroup
object that this check box will be a member of.
state-the initial state value
for this check box.
addNotify
public synchronized void addNotify()
addNotify sets the peer of the check box using the
function getToolkit.createCheckbox.
Using peer interfaces allows the user interface of the check box
to be changed without changing its functionality.
getLabel
public String getLabel()
getLabel returns the check box's label string.
Returns: A String
value representing the check box's label string.
setLabel
public void setLabel(String label)
setLabel modifies the check box's label string.
Parameters: label-a
String value representing
the check box's new label string.
getState
public boolean getState()
getState returns the check box's current state value.
Returns: A boolean value representing the check
box's current state.
setState
public void setState(boolean state)
setState sets the check box to the value represented
by the state parameter.
Parameters: state-a
boolean value containing the new value of the check box's state.
getCheckboxGroup
public CheckboxGroup getCheckboxGroup()
The getCheckboxGroup
method returns the CheckboxGroup
that this check box is a
member of.
Returns: A CheckboxGroup
class that this check box is a member of.
setCheckboxGroup
public void setCheckboxGroup(CheckboxGroup
g)
The setCheckboxGroup
method is used to add this check box to a CheckboxGroup.
Parameters: g-a
CheckboxGroup class to which
this check box is to be added.
Extends: Object
A CheckboxGroup is used to group a set of Checkbox
classes. When check boxes are created within a CheckboxGroup,
only one check box may be selected at one time.
CheckboxGroup Constructor
public CheckboxGroup()
This CheckboxGroup
constructor constructs a CheckboxGroup
instance with no check box members.
getCurrent
public Checkbox getCurrent()
The getCurrent
method returns the current check box.
Returns: A Checkbox
object representing the currently selected check box.
setCurrent
public synchronized void setCurrent(Checkbox
box)
The setCurrent
method sets the current check box in this CheckboxGroup.
Parameters: box-the
Checkbox object that is to
be made current.
toString
public String toString()
toString returns a string containing Checkboxgroup
information.
Returns: A string value containing the CheckboxGroup's
name as well as the name of the currently selected check box.
Extends: MenuItem
A CheckboxMenuItem is a user interface component that
can be added to a menu to represent a boolean value selection.
CheckboxMenuItem Constructor
public CheckboxMenuItem(String label)
This CheckboxMenuItem
constructor creates a CheckboxMenuItem
with a text label containing the string passed in.
Parameters: label-a
string value representing the label of the CheckboxMenuItem
to be displayed.
addNotify
public synchronized void addNotify()
addNotify sets the peer of the CheckboxMenuItem
using the function getToolkit.createCheckboxMenuItem.
Using peer interfaces allows the user interface of the CheckboxMenuItem
to be changed without changing its functionality.
getState
public boolean getState()
getState returns the state value of the CheckboxMenuItem's
check box.
Returns: A boolean value representing the CheckboxMenuItem's
check box state.
setState
public void setState(boolean t)
setState is used to set the CheckboxMenuItem's
check box state value.
Parameters: t-a
boolean value representing the CheckboxMenuItem's
check box state value.
paramString
public String paramString()
paramString returns a string containing CheckboxMenuItem
information
Returns: A string value containing the CheckboxMenuItem's
label as well as the state value of the CheckboxMenuItem's
check box.
Extends: Component
A Choice is a
user interface component that displays a pop-up menu. The current
selection is displayed as the pop-up menu's title.
Choice Constructor
public Choice()
This Choice constructor
creates a default Choice
object that contains no information.
addNotify
public synchronized void addNotify()
addNotify sets the peer of the Choice
using the function getToolkit.createChoice.
Using peer interfaces allows the user interface of the Choice
to be changed without changing its functionality.
countItems
public int countItems()
countItems returns the number of items (or choices)
that are available in this Choice
object.
Returns: An integer value containing the number
of items stored in this Choice
object.
getItem
public String getItem(int index)
The getItem method
returns the choice string at the index represented by the index
value passed in.
Parameters: index-an
integer value representing the index of the string item to be
returned.
Returns: A String
value representing the string at the index passed into this method.
addItem
public synchronized void addItem(String
item)
addItem is used to add a String
to a Choice object's internal
list. The currently selected item will be displayed in the Choice
object's pop-up menu.
Parameters: item-a
String object containing
a string to be added to the choice list.
Throws: NullPointerException
if the string item to be added is null.
getSelectedItem
public String getSelectedItem()
getSelectedItem returns the string value of the currently
selected item.
Returns: A String
value containing the currently selected item's string.
getSelectedIndex
public int getSelectedIndex()
getSelectedIndex returns the index of the currently
selected item.
Returns: An integer value containing the index of
the currently selected item.
select
public synchronized void select(int pos)
This select method
selects the item at the position represented by the pos
parameter.
Parameters: pos-an
integer value representing the position of the item to be selected
Throws: IllegalArgumentException
if the position value passed in is invalid.
select
public void select(String str)
This select method
selects the item represented by the String
parameter.
Parameters: str-a
String value representing
the string value of the choice to be selected.
Extends: Object
The Color class is provided to encapsulate RGB (red-green-blue)
color values.
Member Constants
public final static Color white
Static value representing the color white.
public final static Color lightGray
Static value representing the color light gray.
public final static Color gray
Static value representing the color gray.
public final static Color darkGray
Static value representing the color dark gray.
public final static Color black
Static value representing the color black.
public final static Color red
Static value representing the color red.
public final static Color pink
Static value representing the color pink.
public final static Color orange
Static value representing the color orange.
public final static Color yellow
Static value representing the color yellow.
public final static Color green
Static value representing the color green.
public final static Color magenta
Static value representing the color magenta.
public final static Color cyan
Static value representing the color cyan.
public final static Color blue
Static value representing the color blue.
Color Constructor
public Color(int r, int g, int b)
This Color constructor
accepts as arguments individual red, green, and blue color values.
These values must be in the range 0-255.
Parameters:
r-the red color value.
g-the green color value.
b-the blue color value.
Color Constructor
public Color(int rgb)
This Color constructor
creates a Color object based
on the RGB color value passed in.
Parameters: rgb-an
integer value containing the red, green, and blue color values
that will be used to create this Color
object.
Color Constructor
public Color(float r, float g, float
b)
This Color constructor
create a Color object based
on the color values passed in. This constructor is similar to
the Color constructor that
accepts integer red, green, and blue inputs except that this Color
constructor accepts float
values. These values must be in the
range 0-1.0.
Parameters:
r-the red color value.
g-the green color value.
b-the blue color value.
getRed
public int getRed()
The getRed method
returns the red component of this color.
Returns: An integer value representing this color's
red component.
getGreen
public int getGreen()
The getGreen
method returns the green component of this color.
Returns: An integer value representing this color's
green component.
getBlue
public int getBlue()
The getBlue method
returns the blue component of this color.
Returns: An integer value representing this color's
blue component.
getRGB
public int getRGB()
The getRGB method
returns the RGB value of this color.
Returns: An integer value representing this color's
RGB value in the default RGB color model.
brighter
public Color brighter()
The brighter
method brightens this color by modifying the RGB color value.
This method increases the individual red, green, and blue color
components by a factor of approximately 1.4.
Returns: A Color
object representing a brighter version of the current color.
darker
public Color darker()
The darker method
darkens this color by modifying the RGB color value. This method
decreases the individual red, green, and blue color components
by a factor of approximately 1.4.
Returns: A Color
object representing a darker version of the current color.
hashCode
public int hashCode()
hashCode returns this color's hash code. This is useful
when storing colors in a hash table.
Returns: An integer value representing this color's
hash code.
equals
public boolean equals(Object obj)
The equals method
compares the Object parameter
with this Color object. It
returns a boolean value representing the result of this comparison.
Parameters: obj-an
Object object to be compared
with this color.
Returns: A boolean value representing the result
of the comparison of the Object
parameter to this color.
toString
public String toString()
toString returns a string representation of the Color
class.
Returns: A String
value containing the Color
class's name plus its red, green, and blue values.
getColor
public static Color getColor(String nm)
getColor returns the specified color property based
on the name that is passed in.
Parameters: nm-the
name of the color property.
Returns: A Color
value representing the desired color property.
getColor
public static Color getColor(String nm,
Color v)
getColor returns the specified Color
property of the specified color.
Parameters:
nm-the name of the color
property.
v-the specified color to
be examined.
Returns: A Color
value representing the desired color property.
getColor
public static Color getColor(String nm,
int v)
getColor returns the specified Color
property of the color value that is passed in.
Parameters:
nm-the name of the color
property.
v-the color value.
Returns: A Color
value representing the desired color property.
HSBtoRGB
public static int HSBtoRGB(float hue,
float saturation, float brightness)
HSB stands for hue, saturation, and brightness. To
convert from an HSB value to an RGB value, simply call this function
with the appropriate arguments.
Parameters:
hue-the color's hue
component.
saturation-the color's saturation
component.
brightness-the color's brightness
component.
Returns: An RGB value that corresponds to the HSB
inputs.
RGBtoHSB
public static float[] RGBtoHSB(int r,
int g, int b, float[] hsbvals)
HSB stands for hue, saturation, and brightness. To
convert from an RGB value to an HSB value, simply call this function
with the appropriate arguments.
Parameters:
r-the color's red
component.
g-the color's green component.
b-the color's blue component.
hsbvals-an array that will
be used to store the HSB result values.
Returns: An array containing the resultant HSB values.
getHSBColor
public static Color getHSBColor(float
h, float s, float b)
The getHSBColor
method returns a Color object
representing the RGB value of the input HSB parameters.
Parameters:
h-the color's hue component.
s-the color's saturation
component.
b-the color's brightness
component.
Returns: A Color
object representing the RGB value of the input hue, saturation,
and brightness.
Extends: Object
Implements: ImageObserver
The Component class is used
to represent a generic user interface component. All awt UI components
derive from the Component
class.
getParent
public Container getParent()
getParent returns this component's parent (a Container
class).
Returns: A Container
class representing the component's parent.
getPeer
public ComponentPeer getPeer()
getPeer returns this component's peer (A ComponentPeer
interface).
Returns: A ComponentPeer
interface representing the component's peer.
getToolkit
public Toolkit getToolkit()
getToolkit returns the toolkit of this component.
The toolkit is used to create the peer for the component.
Returns: A Toolkit
class. A toolkit is required to bind the abstract awt classes
to a native toolkit implementation.
isValid
public boolean isValid()
isValid determines whether this component is valid.
A component is considered to be invalid when it is first shown
on the screen.
Returns: A boolean value representing the valid
state of this component.
isVisible
public boolean isVisible()
isVisible determines whether this component is visible.
A component is, by default, visible until told otherwise. A component
can be visible yet not show on the screen if the component's container
is invisible.
Returns: A boolean value representing the visible
state of this component.
isShowing
public boolean isShowing()
isShowing determines whether this component is shown
on the screen. A component can be visible yet not show on the
screen if the component's container is invisible.
Returns: A boolean value representing the show state
of this component.
isEnabled
public boolean isEnabled()
isEnabled determines whether this component is currently
enabled. By default, components are enabled until told otherwise.
Returns: A boolean value representing the enabled
state of this component.
location
public Point location()
location returns the location of this component in
its parent's coordinate space. Note that the Point
object returned contains the top-left corner coordinates of this
component.
Returns: A Point
object containing the location of the component.
size
public Dimension size()
size returns the current size of the component.
Returns: A Dimension
object containing the size of the component.
bounds
public Rectangle bounds()
bounds returns the bounding rectangle of the component.
Returns: A Rectangle
object containing the boundaries for the component.
enable
public synchronized void enable()
The enable method
is used to enable a component. When a component is disabled, it
may be "grayed out" or simply not respond to user inputs.
enable
public void enable(boolean cond)
This enable method
is used to conditionally enable a component. When a component
is disabled, it may be "grayed out" or simply not respond
to user inputs.
Parameters: cond-a
boolean value representing the new enabled state of the component.
disable
public synchronized void disable()
The disable method
disables a component. When a component is disabled, it may be
"grayed out" or simply not respond to user inputs.
show
public synchronized void show()
show shows the component.
show
public void show(boolean cond)
This show method
conditionally shows the component. If the input parameter is true,
the component will be shown. If the input parameter is false,
the component will be hidden.
Parameters: cond-a
boolean value representing the new visible state of the component.
hide
public synchronized void hide()
The hide method
hides the component from view.
getForeground
public Color getForeground()
getForeground returns the foreground color of the
component. If the component's foreground color has not been set,
the foreground color of its parent is returned.
Returns: A Color
object representing the foreground color of this component.
setForeground
public synchronized void setForeground(Color
c)
setForeground sets the foreground color of the component.
Parameters: c-the
new foreground color of this component.
getBackground
public Color getBackground()
getBackground returns the background color of the
component. If the component's background color has not been set,
the background color of its parent is returned.
Returns: A Color
object representing the background color of this component.
setBackground
public synchronized void setBackground(Color
c)
setBackground sets the background color of the component.
Parameters: c-the
new background color of this component.
getFont
public Font getFont()
getFont returns the font of the component. If the
component's font has not been set, the font of its parent is returned.
setFont
public synchronized void setFont(Font
f)
setFont sets the font of the component.
Parameters: f-the
new font of this component.
getColorModel
public synchronized ColorModel getColorModel()
getColorModel gets the color model that will be used
to display this component on an output device.
Returns: A ColorModel
object representing the color model used by this component.
move
public void move(int x, int y)
The move method
moves a component to a new location within its parent's coordinate
space.
Parameters:
x-the new x coordinate
of the component within its parent's coordinate space.
y-the new y coordinate of
the component within its parent's coordinate space.
resize
public void resize(int width, int height)
resize resizes the component to the specified width
and height.
Parameters:
width-the new width
size of the component.
height-the new height size
of the component.
resize
public void resize(Dimension d)
resize resizes the component to the specified dimension.
Parameters: d-a
Dimension object representing
the new size of the component.
reshape
public synchronized void reshape(int
x, int y, int width, int height)
reshape completely changes the bounding box of the
component by changing its size and location.
Parameters:
x-the new x coordinate
of the component within its parent's coordinate space.
y-the new y coordinate of
the component within its parent's coordinate space.
width-the new width size
of the component.
height-the new height size
of the component.
preferredSize
public Dimension preferredSize()
The preferredSize
method returns the preferred size of the component.
Returns: A Dimension
object representing the preferred size of the component.
minimumSize
public Dimension minimumSize()
minimumSize returns the minimum size of the component.
Returns: A Dimension
object representing the minimum size of the component.
layout
public void layout()
The layout method
is called when the component needs to be laid out.
validate
public void validate()
validate validates a component by calling its layout
method.
invalidate
public void invalidate()
invalidate invalidates a component, forcing the component
and all parents above it to be laid out.
getGraphics
public Graphics getGraphics()
getGraphics returns a Graphics
context for the component. If the component is not currently on
the screen, this function will return null.
Returns: A Graphics
object representing the component's graphics context.
getFontMetrics
public FontMetrics getFontMetrics(Font
font)
getFontMetrics returns the current font metrics for
a specified font. If the component is not currently on the screen,
this function will return null.
Parameters: font-a
Font object to be examined.
Returns: A FontMetrics
object representing the component's font metrics.
paint
public void paint(Graphics g)
The paint method
paints the component on the screen using the Graphics
context parameter.
Parameters: g-the
Graphics context that the
component will paint itself onto.
update
public void update(Graphics g)
The update method
repaints the component in response to a call to the repaint
method.
Parameters: g-the
Graphics context that the
component will paint itself onto.
paintAll
public void paintAll(Graphics g)
The paintAll
method is used to paint the component along with all of its subcomponents.
Parameters: g-the
Graphics context that the
component will paint itself onto.
repaint
public void repaint()
repaint is used to force a component to repaint itself.
Calling this function will result in a call to repaint.
repaint
public void repaint(long tm)
This repaint method is used to force a component to
repaint itself in tm milliseconds.
Parameters: tm-the
time span, in milliseconds, from the time this function was called
that the component will repaint itself.
repaint
public void repaint(int x, int y, int
width, int height)
This repaint
method will force the component to repaint part of its surface
area based on the input coordinates.
Parameters:
x-the x coordinate marking
the surface area to be repainted.
y-the y coordinate marking
the surface area to be repainted.
width-the width of the surface
area to be repainted.
height-the height of the
surface area to be repainted.
repaint
public void repaint(long tm, int x, int
y, int width, int height)
This repaint
method will force the component to repaint part of its surface
area based on the input coordinates at a specified time in the
future.
Parameters:
tm-the time, in milliseconds,
from the time this method was called that the component will need
to repaint itself.
x-the x coordinate marking
the surface area to be repainted.
y-the y coordinate marking
the surface area to be repainted.
width-the width of the surface
area to be repainted.
height-the height of the
surface area to be repainted.
print
public void print(Graphics g)
print prints the component using the Graphics
context. The default implementation of this method calls paint.
Parameters: g-the
Graphics context to be printed
on.
printAll
public void printAll(Graphics g)
printAll prints the component and all of its subcomponents
using the Graphics context.
Parameters: g-the
Graphics context to be printed
on.
imageUpdate
public boolean imageUpdate(Image img,
int flags, int x, int y, int w, int h)
imageUpdate repaints the component when the specified
image has changed.
Parameters:
img-an Image
object to be examined for changes.
flags-a flags
parameter contains imaging flags such as FRAMEBITS,
ALLBITS, and SOMEBITS.
x-the x coordinate marking
the surface area to be repainted.
y-the y coordinate marking
the surface area to be repainted.
width-the width of the surface
area to be repainted.
height-the height of the
surface area to be repainted.
Returns: A boolean value that is true
if the image has changed, false
if not.
createImage
public Image createImage(ImageProducer
producer)
createImage creates an Image
using the specified image producer.
Parameters: producer-an
ImageProducer interface that
will be used to produce a new image.
Returns: An Image
object.
createImage
public Image createImage(int width, int height)
This createImage
creates an offscreen Image
object using the specified width and height. This Image
object can be used for things like double buffering.
Parameters:
width-the width of the Image
object to be created.
height-the height of the
Image object to be created.
Returns: An Image
object.
prepareImage
public boolean prepareImage(Image image,
ImageObserver observer)
prepareImage prepares an image for rendering on this
component. Because the Image
is downloaded using a separate thread, the ImageObserver
interface is notified when the image is ready to be rendered.
Parameters:
image-an Image
object that will be rendered on this component.
observer-an Observer
interface that will be notified when the Image
is ready to be rendered.
Returns: A boolean value that is true
if the image has been prepared, false
if not.
prepareImage
public boolean prepareImage(Image
image, int width, int height,
ImageObserver observer)
This prepareImage method
is similar to the prepareImage
method documented previously except that this method scales the
image based on the width and height parameters.
Parameters:
image-an Image
object that will be rendered on this component.
width-the width of the image
to be rendered.
height-the height of the
image to be rendered.
observer-an Observer
interface that will be notified when the Image
is ready to be rendered.
Returns: A boolean value that is true
if the image has been prepared, false
if not.
checkImage
public int checkImage(Image image, ImageObserver
observer)
checkImage checks the status of the construction of
the image to be rendered.
Parameters:
image-an Image
object that will be rendered on this component.
observer-an Observer
interface that will be notified when the Image
is ready to be rendered.
Returns: An integer value that is the boolean OR
of the ImageObserver flags
for the data that is currently available.
checkImage
public int checkImage(Image image, int
width, int height, ImageObserver
observer)
This checkImage
method checks the status of the construction of a scaled representation
of this image.
Parameters:
image-an Image
object that will be rendered on this component.
width-the width of the image
to be checked.
height-the height of the
image to be checked.
observer-an Observer
interface that will be notified when the image is ready to be
rendered.
Returns: An integer value that is the boolean OR
of the ImageObserver flags
for the data that is currently available.
inside
public synchronized boolean inside(int
x, int y)
The inside method
determines whether the x and y coordinates are within the bounding
rectangle of the component.
Parameters:
x-the x coordinate to be
examined.
y-the y coordinate to be
examined.
Returns: A boolean value representing the result
of the coordinate check.
locate
public Component locate(int x, int y)
locate returns the Component
at the specified x and y coordinates.
Parameters:
x-the x coordinate to be
examined.
y-the y coordinate to be
examined.
Returns: The Component
that is found at the specified x and y coordinates.
deliverEvent
public void deliverEvent(Event e)
deliverEvent delivers an event to the component.
Parameters: e-an
Event object encapsulating
the event.
postEvent
public boolean postEvent(Event e)
postEvent posts an event to the component resulting
in a call to handleEvent.
Parameters: e-an
Event object encapsulating
the event.
Returns: A boolean value that is true
if the event was handled, false
if not.
handleEvent
public boolean handleEvent(Event evt)
handleEvent is used to handle individual events by
the component.
Parameters: evt-an
Event object encapsulating
the event.
Returns: A boolean value that is true
if the event was handled, false
if not.
mouseDown
public boolean mouseDown(Event evt, int
x, int y)
The mouseDown
method is called if the mouse is down.
Parameters:
evt-an Event
object encapsulating the event.
x-the x coordinate of the
mouse down click point.
y-the y coordinate of the
mouse down click point.
Returns: A boolean value that is true
if the event was handled, false
if not.
mouseDrag
public boolean mouseDrag(Event evt, int
x, int y)
The mouseDrag
method is called if the mouse is dragged.
Parameters:
evt-an Event
object encapsulating the event.
x-the x coordinate of the
current mouse point coordinate.
y-the y coordinate of the
current mouse point coordinate.
Returns: A boolean value that is true
if the event was handled, false
if not.
mouseUp
public boolean mouseUp(Event evt, int
x, int y)
The mouseUp method
is called when the mouse button is let up.
Parameters:
evt-an Event
object encapsulating the event.
x-the x coordinate of the
mouse up point.
y-the y coordinate of the
mouse up point.
Returns: A boolean value that is true
if the event was handled, false
if not.
mouseMove
public boolean mouseMove(Event evt, int
x, int y)
The mouseMove
method is called if the mouse is moved.
Parameters:
evt-an Event
object encapsulating the event.
x-the x coordinate of the
current mouse point coordinate.
y-the y coordinate of the
current mouse point coordinate.
Returns: A boolean value that is true
if the event was handled, false
if not.
mouseEnter
public boolean mouseEnter(Event evt,
int x, int y)
The mouseEnter
method is called if the mouse enters the component.
Parameters:
evt-an Event
object encapsulating the event.
x-the x coordinate of the
current mouse point coordinate.
y-the y coordinate of the
current mouse point coordinate.
Returns: A boolean value that is true
if the event was handled, false
if not.
mouseExit
public boolean mouseExit(Event evt, int
x, int y)
The mouseExit
method is called if the mouse exits the component.
Parameters:
evt-an Event
object encapsulating the event.
x-the x coordinate of the
mouse exit point.
y-the y coordinate of the
mouse exit point.
Returns: A boolean value that is true
if the event was handled, false
if not.
keyDown
public boolean keyDown(Event evt, int
key)
The keyDown method
is called when a key is pressed.
Parameters:
evt-an Event
object encapsulating the event.
key-an integer value representing
the code of the key that was pressed.
Returns: A boolean value that is true
if the event was handled, false
if not.
keyUp
public boolean keyUp(Event evt, int key)
The keyUp method
is called when a key is let up.
Parameters:
evt-an Event
object encapsulating the event.
key-an integer value representing
the code of the key that was pressed.
Returns: A boolean value that is true
if the event was handled, false
if not.
action
public boolean action(Event evt, Object
what)
The action method
is called if an action occurs within the component.
Parameters:
evt-an Event
object encapsulating the event.
what-an object representing
the action that is occurring.
Returns: A boolean value that is true
if the event was handled, false
if not.
addNotify
public void addNotify()
addNotify notifies a component to create a peer object.
removeNotify
public synchronized void removeNotify()
removeNotify notifies a component to destroy the peer
object.
gotFocus
public boolean gotFocus(Event evt, Object
what)
The gotFocus
method is called when the component receives the input focus.
Parameters:
evt-an Event
object encapsulating the event.
what-an object representing
the action that is occurring.
Returns: A boolean value that is true
if the event was handled, false
if not.
lostFocus
public boolean lostFocus(Event evt, Object
what)
The lostFocus
method is called when the component loses the input focus.
Parameters:
evt-an Event
object encapsulating the event.
what-an object representing
the action that is occurring.
Returns: A boolean value that is true
if the event was handled, false
if not.
requestFocus
public void requestFocus()
The requestFocus
method requests the current input focus. If this method is successful,
gotFocus will then be called.
nextFocus
public void nextFocus()
The nextFocus
method switches the focus to the next component. The next component
can be determined by examining the tab order of the components
on a form.
toString
public String toString()
toString returns a string representation of the Component
class.
Returns: A String
value containing the Component
class's name plus its x, y, height, and width values.
list
public void list()
The list method
prints a listing of the component to the print stream.
list
public void list(PrintStream out)
This list method
prints a listing of the component to the specified output stream.
Parameters: out-a
PrintStream object.
list
public void list(PrintStream out, int
indent)
This list method
prints a listing of the component to the specified output stream
at the specified indention.
Parameters:
out-a PrintStream
object.
indent-an integer value representing
the amount to be indented.
Extends: Component
A Container class
is defined as a class that can contain other components.
countComponents
public int countComponents()
countComponents returns the number of components contained
within the container.
Returns: An integer value representing the number
of components within the container.
getComponent
public synchronized Component getComponent(int
n)
The getComponent
method returns the component at the specified index.
Parameters: n-an
integer value representing the index at which to retrieve a component.
Returns: A Component
object within the container.
getComponents
public synchronized Component[] getComponents()
getComponents returns an array of Component
objects contained within the Container.
Returns: An array of Component
objects contained within the container.
insets
public Insets insets()
The insets methods
returns the borders of this container.
Returns: An Insets
object representing the insets of the container.
add
public Component add(Component comp)
The add method
adds a Component to the container
at the end of the container's array of components.
Parameters: comp-the
component to be added.
Returns: The Component
object that was added to the container's list.
add
public synchronized Component add(Component
comp, int pos)
This add method
adds a Component to the container
at the specified index in the container's array of components.
Parameters:
comp-the component
to be added.
pos-the position the component
is to be added at.
Returns: The Component
object that was added to the container's list.
add
public synchronized Component add(String
name, Component comp)
This add method
adds a Component using the
Component argument and that
Component's name.
Parameters:
name-a String
representing the name of the component.
comp-the component to be
added.
Returns: The Component
object that was added to the container's list.
remove
public synchronized void remove(Component
comp)
The remove method
removes the specified component from the Container's
list.
Parameters: comp-the
component to be removed.
removeAll
public synchronized void removeAll()
The removeAll
method removes all components from within the Container.
getLayout
public LayoutManager getLayout()
getLayout returns this container's layout manager.
Returns: A layout manager interface representing
the container's LayoutManager.
setLayout
public void setLayout(LayoutManager mgr)
setLayout sets the current layout manager of the container.
Parameters: mgr-the
layout manager that will control the layouts of this Container's
components.
layout
public synchronized void layout()
The layout method
is called to perform a layout on this component.
validate
public synchronized void validate()
The validate
method refreshes the container and all of the components within
it by validating the container and all of its components.
preferredSize
public synchronized Dimension preferredSize()
preferredSize returns the preferred size of this container.
Returns: A Dimension
object representing the preferred size of this Container.
minimumSize
public synchronized Dimension minimumSize()
minimumSize returns the minimum size of this container.
Returns: A Dimension
object representing the minimum size of this Container.
paintComponents
public void paintComponents(Graphics
g)
The paintComponents
method is used to paint each of the components within the container.
Parameters: g-the
Graphics context that the
container's components will be painted on.
printComponents
public void printComponents(Graphics
g)
The printComponents
method is used to print each of the components within the container.
Parameters: g-the
Graphics context that the
container's components will be printed on.
deliverEvent
public void deliverEvent(Event e)
deliverEvent locates the appropriate component within
the container that the event applies to and delivers the event
to that component.
Parameters: e-the
event to be delivered.
locate
public Component locate(int x, int y)
The locate method
locates and returns the component that lies at the specified x
and y coordinates within the container.
Parameters:
x-the x coordinate of the
component to be located.
y-the y coordinate of the
component to be located.
addNotify
public synchronized void addNotify()
addNotify notifies the container to create a peer
interface. This method will also notify each of the container's
components to do likewise.
removeNotify
public synchronized void removeNotify()
removeNotify notifies the container to remove its
peer. This method will also notify each of the container's components
to do likewise.
list
public void list(PrintStream out, int
indent)
The list method
prints a list for each component within the container to the specified
output stream at the specified indentation.
Parameters:
out-a PrintStream
object.
indent-an integer amount
representing the value to indent the list.
Extends: Window
The Dialog class
is used to create a window that can be closed by the user. Dialogs
are normally temporary windows that are used for inputting information.
Dialog Constructor
public Dialog(Frame parent, boolean modal)
This Dialog constructor
constructs a Dialog object
from a parent Frame object.
This dialog is initially invisible.
Parameters:
parent-the parent frame of
the dialog.
modal-a boolean value designating
this dialog to be either modal or nonmodal.
Dialog Constructor
public Dialog(Frame parent, String title,
boolean modal)
This Dialog constructor
constructs a Dialog object
from a parent Frame object.
This dialog is initially invisible.
Parameters:
parent-the parent frame of
the dialog.
title-a String
value representing the title to be displayed for this dialog.
modal-a boolean value designating
this dialog to be either modal or nonmodal.
addNotify
public synchronized void addNotify()
The addNotify
method creates the dialog's peer. Making use of a peer interface
allows the dialog's appearance to be changed without changing
its functionality.
isModal
public boolean isModal()
isModal returns the modal status of the dialog.
Returns: A boolean value representing the dialog's
modal status. If this is true,
the dialog is modal. If false,
the dialog is nonmodal.
getTitle
public String getTitle()
getTitle returns the dialog's title string.
Returns: A String
value representing the title string of the dialog.
setTitle
public void setTitle(String title)
The setTitle
method sets the dialog's title string.
Parameters: title-a
String value representing
the dialog's new title.
isResizable
public boolean isResizable()
The isResizable
method is called to determine whether or not this dialog can be
resized.
Returns: A boolean value that is true
if the dialog is resizable, false
if it is not.
setResizable
public void setResizable(boolean resizable)
The setResizable
method is used to change whether a dialog can be resized.
Parameters: resizable-a
boolean value that is true
if the dialog is to be resizable and false
if not.
Extends: Object
A Dimension class is used to encapsulate an object's
height and width.
Member Variables
public int width
The width instance
variable contains the integer value representing the Dimension's
width value.
public int height
The height instance
variable contains the integer value representing the Dimension's
height value.
Dimension Constructor
public Dimension()
This Dimension
constructor constructs an empty Dimension
object.
Dimension Constructor
public Dimension(Dimension d)
This Dimension
constructor constructs a Dimension
object from an existing Dimension
object.
Parameters: d-a
Dimension object whose values
will be used to create the new dimension.
Dimension Constructor
public Dimension(int width, int height)
This Dimension
constructor constructs a Dimension
object based on the width
and height input parameters.
Parameters:
width-an integer value representing
the width of the new dimension.
height-an integer value representing
the height of the new dimension.
toString
public String toString()
The toString
method is used to return a string representation of this Dimension
object.
Returns: A String
containing this dimension's height and width values.
Extends: Object
The Event class
is used to encapsulate GUI event's in a platform-independent manner.
Member Constants
public static final int SHIFT_MASK
The SHIFT_MASK value represents the Shift Modifier constant.
public static final int CTRL_MASK
The CTRL_MASK value represents the Control Modifier constant.
public static final int META_MASK
The META_MASK value represents the Meta Modifier constant.
public static final int ALT_MASK
The ALT_MASK value represents the Alt Modifier constant.
public static final int HOME
The HOME value represents the Home key.
public static final int END
The END value represents the End key.
public static final int PGUP
The PGUP value represents the Page Up key.
public static final int PGDN
The PGDN value represents the Page Down key.
public static final int UP
The UP value represents the up-arrow key.
public static final int DOWN
The DOWN value represents the down-arrow key.
public static final int LEFT
The LEFT value represents the left-arrow key.
public static final int RIGHT
The RIGHT value represents the right-arrow key.
public static final int f1
The f1 value represents the f1 key.
public static final int f2
The f2 value represents the f2 key.
public static final int f3
The f3 value represents the f3 key.
public static final int f4
The f4 value represents the f4 key.
public static final int f5
The f5 value represents the f5 key.
public static final int f6
The f6 value represents the f6 key.
public static final int f7
The f7 value represents the f7 key.
public static final int f8
The f8 value represents the f8 key.
public static final int f9
The f9 value represents the f9 key.
public static final int f10
The f10 value represents the f10 key.
public static final int f11
The f11 value represents the f11 key.
public static final int f12
The f12 value represents the f12 key.
public static final int WINDOW_DESTROY
The WINDOW_DESTROY value represents the destroy window event.
public static final int WINDOW_EXPOSE
The WINDOW_EXPOSE value represents the expose window event.
public static final int WINDOW_ICONIFY
The WINDOW_ICONIFY value represents the iconify window event.
public static final int WINDOW_DEICONIFY
The DEICONIFY_WINDOW value represents the deiconify window event.
public static final int WINDOW_MOVED
The WINDOW_MOVED value represents the window moved event.
public static final int KEY_PRESS
The KEY_PRESS value represents the keypress event.
public static final int KEY_RELEASE
The KEY_RELEASE value represents the key release event.
public static final int KEY_ACTION
The KEY_ACTION value represents the key action keyboard event.
public static final int KEY_ACTION_RELEASE
The KEY_ACTION_RELEASE value represents the key action release
keyboard event.
public static final int MOUSE_DOWN
The MOUSE_DOWN value represents the mouse down event.
public static final int MOUSE_UP
The MOUSE_UP value represents the mouse up event.
public static final int MOUSE_MOVE
The MOUSE_MOVE value represents the mouse move event.
public static final int MOUSE_ENTER
The MOUSE_ENTER value represents the mouse enter event.
public static final int MOUSE_EXIT
The MOUSE_EXIT value represents the mouse exit event.
public static final int MOUSE_DRAG
The MOUSE_DRAG value represents the mouse drag event.
public static final int SCROLL_LINE_UP
The SCROLL_LINE_UP value represents the line up scroll event.
public static final int SCROLL_LINE_DOWN
The SCROLL_LINE_DOWN value represents the line down scroll event.
public static final int SCROLL_PAGE_UP
The SCROLL_PAGE_UP value represents the page up scroll event.
public static final int SCROLL_PAGE_DOWN
The SCROLL_PAGE_DOWN value represents the page down scroll event.
public static final int SCROLL_ABSOLUTE
The SCROLL_ABSOLUTE value represents the absolute scroll event.
public static final int LIST_SELECT
The LIST_SELECT value represents the select list event.
public static final int LIST_DESELECT
The LIST_DESELECT value represents the deselect list event.
public static final int ACTION_EVENT
The ACTION_EVENT value represents an action event.
public static final int LOAD_FILE
The LOAD_FILE value represents a file load event.
public static final int SAVE_FILE
The SAVE_FILE value represents a file save event.
public static final int GOT_FOCUS
The GOT_FOCUS value represents a got focus event.
public static final int LOST_FOCUS
The LOST_FOCUS value represents a lost focus event.
Member Variables
public Object target
The target instance variable represents the object that is the
target of the event.
public long when
The when instance variable represents the time stamp of the event.
public int id
The id instance variable represents the type of the event.
public int x
The x instance variable represents the x coordinate of the event.
public int y
The y instance variable represents the y coordinate of the event.
public int key
The key instance variable represents the key that was pressed
to trigger the keyboard event.
public int modifiers
The modifiers instance variable represents the state of the modifier
keys.
public int clickCount
The clickCount instance variable represents the number of clicks
during the mouse down event. If this event wasn't triggered by
a mouse down action, this value will be 0. It will be 1 for a
single click, and 2 for a double click.
public Object arg
The arg instance variable represents an arbitrary argument.
public Event evt
The evt instance variable represents the next event. This is useful
when multiple events will be stored in an array or linked list.
Event Constructor
public Event(Object target, long when,
int id, int x, int y, int key, int modifiers, Object arg)
This Event constructor
constructs an event using the target, current time, event ID,
location, key pressed and modifiers, and some argument.
Parameters:
target-the target object
for the event.
when-the time stamp for the
event.
id-the event type.
x-the x coordinate of the
event.
y-the y coordinate of the
event.
key-the key pressed that
triggered a keyboard event.
modifiers-the state of the
modifier keys.
arg-an arbitrary argument.
Event Constructor
public Event(Object target, long when,
int id, int x, int y, int key, int modifiers)
This Event constructor
constructs an event using the target, current time, event ID,
location, key pressed, and modifiers.
Parameters:
target-the target
object for the event.
when-the time stamp for the
event.
id-the event type.
x-the x coordinate of the
event.
y-the y coordinate of the
event.
key-the key pressed that
triggered a keyboard event.
Event Constructor
public Event(Object target, int id, Object
arg)
This Event constructor
constructs an event using the target, event ID, and some argument.
Parameters:
target-the target object
for the event.
id-the event type.
arg-an arbitrary argument.
translate
public void translate(int x, int y)
The translate
method translates coordinates for a given component. If the object
sending this event has targeted a certain component, this method
will translate the coordinates to make sense for that particular
component.
Parameters:
x-the x coordinate.
y-the y coordinate.
shiftDown
public boolean shiftDown()
The shiftDown
method returns the current state of the Shift key.
Returns: A boolean value that is true
if the Shift key is down, false
if it is up.
controlDown
public boolean controlDown()
The controlDown
method returns the current state of the Ctrl key.
Returns: A boolean value that is true
if the Ctrl key is down, false
if it is up.
metaDown
public boolean metaDown()
The metaDown
method returns the current state of the Meta key.
Returns: A boolean value that is true
if the meta key is down, false
if it is up.
toString
public String toString()
The toString
method returns the string representation of the current event.
Returns: A String
value containing information on the event, including the id,
x, y,
key, shiftDown,
controlDown, and metaDown
values.
Extends: Dialog
A FileDialog
is presented to a user in order for that user to select a file.
This dialog is a modal dialog, therefore the calling thread will
be blocked until this dialog exits.
Member Constants
public static final int LOAD
The LOAD static
value represents the file load variable.
public static final int SAVE
The SAVE static
value represents the file save variable.
FileDialog Constructor
public FileDialog(Frame parent, String
title)
This FileDialog
constructor constructs a file dialog using a parent frame and
a title string.
Parameters:
parent-the parent frame of
the file dialog.
title-a String
containing the dialog's title.
FileDialog Constructor
public FileDialog(Frame parent, String
title, int mode)
This FileDialog
constructor constructs a file dialog using a parent frame, a title
string, and a mode value representing either a load or save dialog.
Parameters:
parent-the parent frame of
the file dialog.
title-a String
containing the dialog's title.
mode-an integer value representing
the dialog mode (LOAD or
SAVE).
addNotify
public synchronized void addNotify()
addNotify notifies FileDialog
to create a peer. Using a peer interface allows the user interface
of the file dialog to be changed without changing its functionality.
getMode
public int getMode()
getMode returns the current mode of the file dialog.
Returns: An integer value representing the current
mode (LOAD or SAVE)
of the file dialog.
getDirectory
public String getDirectory()
The getDirectory
method returns the current directory of the file dialog.
Returns: A String
value representing FileDialog's
current directory.
setDirectory
public void setDirectory(String dir)
The setDirectory
method is used to set the current directory of the FileDialog.
Parameters: dir-a
String value representing
the directory to be set.
getFile
public String getFile()
The getFile method
returns the currently selected file within FileDialog.
Returns: A String
value representing the file dialog's current file.
setFile
public void setFile(String file)
The setFile method
is used to set the current file of the file dialog.
Parameters: file-a
String value representing
the file to be set.
Extends: Object
Implements: LayoutManager
A FlowLayout implements the
LayoutManager interface.
This class is used to lay out buttons from left to right until
no more buttons fit on the Panel.
Member Constants
public static final int LEFT
The LEFT static
value represents the left alignment variable.
public static final int CENTER
The CENTER static
value represents the center alignment variable.
public static final int RIGHT
The RIGHT static
value represents the right alignment variable.
FlowLayout Constructor
public FlowLayout()
This FlowLayout
constructor constructs a default FlowLayout
class with a centered alignment.
FlowLayout Constructor
public FlowLayout(int align)
This FlowLayout
constructor constructs a FlowLayout
class using the specified alignment.
Parameters: align-the
alignment value (LEFT, CENTER,
or RIGHT).
FlowLayout Constructor
public FlowLayout(int align, int hgap,
int vgap)
This FlowLayout
constructor constructs a FlowLayout
class using the specified alignment and gap values.
Parameters:
align-the alignment
value (LEFT, CENTER,
or RIGHT).
hgap-the horizontal gap value.
vgap-the vertical gap value.
addLayoutComponent
public void addLayoutComponent(String
name, Component comp)
The addLayoutComponent
method adds a component to the FlowLayout
class.
Parameters:
name-a String
value representing the name of the Component
to be added.
comp-the Component
object to be added to FlowLayout.
removeLayoutComponent
public void removeLayoutComponent(Component
comp)
removeLayoutComponent removes a component from the
FlowLayout class.
Parameters: comp-a
Component object to be removed
from FlowLayout.
preferredLayoutSize
public Dimension preferredLayoutSize(Container
target)
The preferredLayoutSize
method returns the preferred size for this FlowLayout
given the components in the specified container.
Parameters: target-a
Container object that will
be examined to determine the preferred layout size for this FlowLayout.
Returns: A Dimension
class containing the preferred size of the FlowLayout.
minimumLayoutSize
public Dimension minimumLayoutSize(Container
target)
The minimumLayoutSize
method returns the minimum size for this FlowLayout
given the components in the specified container.
Parameters: target-a
Container object that will
be examined to determine the minimum layout size for this FlowLayout.
Returns: A Dimension
class containing the minimum size of the FlowLayout.
layoutContainer
public void layoutContainer(Container
target)
The layoutContainer
method lays out the components within the specified container.
Parameters: target-a
Container class containing
a set of components that will be laid out according to the FlowLayout
rules.
toString
public String toString()
The toString
method returns a string representation of the FlowLayout
class.
Returns: A String
containing information about the FlowLayout,
including the FlowLayout's
name, alignment,
hgap, and vgap
values.
Extends: Object
This class is used to encapsulate a font.
Member Constants
public static final int PLAIN
The PLAIN static
value represents the plain style constant.
public static final int BOLD
The BOLD static
value represents the bold style constant.
public static final int ITALIC
The ITALIC static
value represents the italic style constant.
Font Constructor
public Font(String name, int style, int
size)
The Font constructor
constructs a font of the specified name, style, and size.
Parameters:
name-the name of the font
to be created.
style-the style (PLAIN
and/or BOLD and/or ITALIC)
of the font to be created.
size-the size of the font
to be created.
getFamily
public String getFamily()
getFamily returns the font family that this font belongs
to.
Returns: A String
value representing the font's family name.
getName
public String getName()
getName returns the name of the Font
object.
Returns: A String
value representing the name of the font.
getStyle
public int getStyle()
getStyle returns the style of the Font
object.
Returns: An integer value representing the style
of the font.
getSize
public int getSize()
getSize returns the size of the Font
object.
Returns: An integer value representing the point
size of the font.
isPlain
public boolean isPlain()
isPlain returns the plain style state of the Font.
Returns: A boolean value that is true
if the font is plain, false
if not.
isBold
public boolean isBold()
isBold returns the bold style state of the Font.
Returns: A boolean value that is true
if the font is bold, false
if not.
isItalic
public boolean isItalic()
isItalic returns the italic style state of the Font.
Returns: A boolean value that is true
if the font is italic, false
if not.
getFont
public static Font getFont(String nm)
getFont returns a Font
based on the system properties list and the name passed in.
Parameters: nm-the
name of the font to be returned from the system properties list.
Returns: A Font
object based on the system properties list.
getFont
public static Font getFont(String nm,
Font font)
This getFont
method returns a Font based
on the system properties list, the name passed in, and a default
font in case the specified name is not found.
Parameters:
nm-the name of the
font to be returned from the system properties list.
font-the default font to
be returned if the font specified by the nm
variable is not found.
Returns: A Font
object based on the system properties list.
hashCode
public int hashCode()
hashCode returns a hash code for this font.
Returns: An integer value representing the hash
code for the font.
equals
public boolean equals(Object obj)
equals compares an object with the Font
object.
Parameters: obj-the
object to compare the font with.
Returns: A boolean value that is true
if the objects are equal, false
if not.
toString
public String toString()
The toString
method is used to return a string representation of the font.
Returns: A String
value containing the font family, name, style, and size values.
Extends: Object
The FontMetrics
class is used to encapsulate a FontMetrics
object containing font information.
getFont
public Font getFont()
The getFont method
returns the font that these FontMetrics
refer to.
Returns: A Font
object.
getLeading
public int getLeading()
The getLeading
method gets the line spacing of the font.
Returns: An integer value containing the standard
leading, or line spacing, of the font. The line spacing of a font
is the space reserved between the descent of a text character
and the ascent of a text character below it.
getAscent
public int getAscent()
The getAscent
method gets the ascent value for a font.
Returns: An integer value containing the ascent
value for a font. This value is the distance from the bottom of
a character to its top.
getDescent
public int getDescent()
The getDescent
method gets the descent value for a font.
Returns: An integer value containing the descent
value for a font. This value is the bottom coordinate of a character.
getHeight
public int getHeight()
The getHeight
method gets the height of a line of text using the current Font.
Returns: An integer value containing the height
of a line of text. This value is calculated by adding the ascent,
descent, and leading values.
getMaxAscent
public int getMaxAscent()
getMaxAscent returns the maximum value of a font's
ascent.
Returns: An integer value containing the maximum
value of a font's ascent for all of that
font's characters.
getMaxDescent
public int getMaxDescent()
getMaxDescent returns the maximum value of a font's
descent.
Returns: An integer value containing the maximum
value of a font's descent for all of that font's characters.
getMaxDecent
public int getMaxDecent()
The getMaxDecent
method is provided only for backward compatibility. It simply
calls the getMaxDescent method.
Returns: An integer value containing the maximum
value of a font's descent for all of that font's characters.
getMaxAdvance
public int getMaxAdvance()
The getMaxAdvance
method gets the maximum amount for a character's advance value.
The advance is the amount that is advanced from the beginning
of one character to the next character.
charWidth
public int charWidth(int ch)
charWidth returns the width of a particular character
for the current font.
Parameters: ch-an
integer value representing the character to be checked.
Returns: An integer value representing the width
of the specified character.
charWidth
public int charWidth(char ch)
This charWidth
method returns the width of a particular character for the current
font.
Parameters: ch-a
string value representing the character to be checked.
Returns: An integer value representing the width
of the specified character.
stringWidth
public int stringWidth(String str)
The stringWidth
method returns the width of a specified string using the current
font.
Parameters: str-a
string representing the characters to be checked.
Returns: An integer value representing the advance
width of the specified string.
charsWidth
public int charsWidth(char data[], int
off, int len)
The charsWidth
method returns the width of a specified string of characters using
the current font.
Parameters:
data-an array of characters
to be checked.
off-an integer value representing
the offset into the array where the string will start.
len-the number of characters
to be measured.
Returns: An integer value representing the advance
width of the specified string.
bytesWidth
public int bytesWidth(byte data[], int
off, int len)
The bytesWidth
method returns the width of a specified array of bytes
Parameters:
data-an array of bytes to
be checked.
off-an integer value representing
the offset into the array where the string will start.
len-the number of bytes to
be measured.
Returns: An integer value representing the advance
width of the specified string.
getWidths
public int[] getWidths()
The getWidths
method gets the advance widths of the first 256 characters of
the font.
Returns: An integer array containing the advance
widths of the first 256 characters of the font.
toString
public String toString()
The toString
method is used to return a string representation of the FontMetrics
class.
Returns: A String
value containing the font metrics' name, font, ascent, descent,
and height.
Extends: Window
Implements: MenuContainer
A Frame class
represents a basic window.
Member Constants
public static final int DEFAULT_CURSOR
The DEFAULT_CURSOR static value represents the default cursor.
public static final int CROSSHAIR_CURSOR
The CROSSHAIR_CURSOR static value represents the crosshair cursor.
public static final int TEXT_CURSOR
The TEXT_CURSOR static value represents the text cursor.
public static final int WAIT_CURSOR
The WAIT_CURSOR static value represents the wait cursor.
public static final int SW_RESIZE_CURSOR
The SW_RESIZE_CURSOR static value represents the southwest resize
cursor.
public static final int SE_RESIZE_CURSOR
The SE_RESIZE_CURSOR static value represents the southeast resize
cursor.
public static final int NW_RESIZE_CURSOR
The NW_RESIZE_CURSOR static value represents the northwest resize
cursor.
public static final int NE_RESIZE_CURSOR
The NE_RESIZE_CURSOR static value represents the northeast resize
cursor.
public static final int N_RESIZE_CURSOR
The N_RESIZE_CURSOR static value represents the north resize cursor.
public static final int S_RESIZE_CURSOR
The S_RESIZE_CURSOR static value represents the south resize cursor.
public static final int W_RESIZE_CURSOR
The W_RESIZE_CURSOR static value represents the west resize cursor.
public static final int E_RESIZE_CURSOR
The E_RESIZE_CURSOR static value represents the east resize cursor.
public static final int HAND_CURSOR
The HAND_CURSOR static value represents the hand cursor.
public static final int MOVE_CURSOR
The MOVE_CURSOR static value represents the move cursor.
Frame Constructor
public Frame()
The Frame constructor
constructs a default frame that is invisible and that uses the
BorderLayout layout manager.
Frame Constructor
public Frame(String title)
This Frame constructor
constructs a default frame using the specified title that is invisible
and that uses the BorderLayout
layout manager.
Parameters: title-a
String value containing the
frame's title string.
addNotify
public synchronized void addNotify()
The addNotify
method creates a peer interface for the frame. Peer interfaces
allow the user interface of the frame to be changed without changing
its functionality.
getTitle
public String getTitle()
getTitle returns the frame's title.
Returns: A String
value representing the title of the frame.
setTitle
public void setTitle(String title)
setTitle sets the frame's title.
Parameters: title-a
String value representing
the title of the frame.
getIconImage
public Image getIconImage()
The getIconImage
method returns an image representing the iconized image of the
frame.
Returns: An Image
class representing the iconized image of the frame.
setIconImage
public void setIconImage(Image
image)
setIconImage is used to set
the image that will be used when the frame is iconized.
Parameters: image-an
Image class that will be
displayed when the frame is iconized.
getMenuBar
public MenuBar getMenuBar()
The getMenuBar
method returns the MenuBar
object that is contained within this frame.
Returns: A MenuBar
class that is displayed within this frame.
setMenuBar
public synchronized void setMenuBar(MenuBar
mb)
setMenuBar sets the MenuBar
class to be displayed within the frame.
Parameters: mb-a
MenuBar object to be used
for the frame's menu bar.
remove
public synchronized void remove(MenuComponent
m)
The remove method
removes the specified MenuComponent
from the frame.
Parameters: A MenuComponent
object that is to be removed from the frame.
dispose
public synchronized void dispose()
The dispose method
disposes of the frame. This method first disposes of the frame's
menu bar, and then disposes of the frame itself.
isResizable
public boolean isResizable()
The isResizable
method returns the frame's resizable state.
Returns: A boolean value that is true
if the frame can be resized, false
if not.
setResizable
public void setResizable(boolean resizable)
The setResizable
method sets the frame's resizable state.
Returns: A boolean value that is true
if the frame can be resized, false
if not.
setCursor
public void setCursor(int cursorType)
The setCursor
method sets the cursor to be displayed within the frame.
Returns: An integer value representing the cursor
to be displayed, which can be any of the frame's static values
such as WAIT_CURSOR, MOVE_CURSOR,
and so on.
getCursorType
public int getCursorType()
The getCursorType
method returns the frame's current cursor type.
Returns: An integer value representing the current
cursor type for the frame.
Extends: Object
The Graphics
class represents the base class for all types of graphics contexts.
create
public abstract Graphics create()
This abstract function creates a new Graphics
object.
create
public Graphics create(int x, int y,
int width, int height)
The create method
creates a new Graphics object
using the specified parameters.
Parameters:
x-the x coordinate of the
graphics context.
y-the y coordinate of the
graphics context.
width-the width of the graphics
context.
height-the height of the
graphics context.
Returns: A Graphics
class corresponding to the create
method's specifications.
translate
public abstract void translate(int x,
int y)
The translate
method translates the Graphics
object to the new x and y origin coordinates.
Parameters:
x-the new x origin coordinate.
y-the new y origin coordinate.
getColor
public abstract Color getColor()
The getColor
method returns the current color.
Returns: A Color
object representing the current color used for drawing operations.
setColor
public abstract void setColor(Color c)
The setColor
method sets the current color.
Parameters: c-a
Color object to be used for
graphics drawing operations.
setPaintMode
public abstract void setPaintMode()
The setPaintMode
method sets the paint mode to overwrite the destination with the
current color.
setXORMode
public abstract void setXORMode(Color
c1)
The setXORMode
method sets the paint mode to XOR
the current colors with the specified color. This means that when
redrawing over an existing area, colors that match the current
color will be changed to the specified color c1
and vice versa.
Parameters: c1-the
Color object specified to
be XOR'd with the current
color.
getFont
public abstract Font getFont()
The getFont method
returns the current font used for the graphics context.
Returns: A Font
object representing the graphics context's current font.
setFont
public abstract void setFont(Font font)
The setFont method
sets the graphics context's font.
Parameters: A Font
object that will be used as the current font.
getFontMetrics
public FontMetrics getFontMetrics()
The getFontMetrics
method will return the font metrics for the current font.
Returns: A FontMetrics
object representing the font metrics for the current font.
getFontMetrics
public abstract FontMetrics getFontMetrics(Font
f)
This getFontMetrics
method will return the font metrics for the specified font.
Returns: A FontMetrics
object representing the font metrics for the specified font.
getClipRect
public abstract Rectangle getClipRect()
The getClipRect
method will return the current clipping rectangle for the Graphics
class.
Returns: A Rectangle
object representing the current clipping rectangle.
clipRect
public abstract void clipRect(int x,
int y, int width, int height)
The clipRect
method will set the current clipping rectangle for the Graphics
class.
Parameters:
x-the x coordinate of the
clipping rectangle.
y-the y coordinate of the
clipping rectangle.
width-the width of the clipping
rectangle.
height-the height of the
clipping rectangle.
copyArea
public abstract void copyArea(int x,
int y, int width, int height, int dx,
int dy)
The copyArea
method copies a specified section of the screen to another location.
Parameters:
x-the x coordinate of the
region to be copied.
y-the y coordinate of the
region to be copied.
width-the width of the region
to be copied.
height-the height of the
region to be copied.
dx-the horizontal distance
of the region to be copied to.
dy-the vertical distance
of the region to be copied to.
drawLine
public abstract void drawLine(int x1, int y1, int x2, int y2)
The drawLine
method will draw a line on the graphics context from one point
to another point specified by the input parameters.
Parameters:
x1-the x coordinate of the
line's starting point.
y1-the y coordinate of the
line's starting point.
x2-the x coordinate of the
line's ending point.
y2-the y coordinate of the
line's ending point.
fillRect
public abstract void fillRect(int x,
int y, int width, int height)
The fillRect
method fills the specified rectangular region with the current
color.
Parameters:
x-the x coordinate
of the rectangle to be filled.
y-the y coordinate of the
rectangle to be filled.
width-the width of the rectangle
to be filled.
height-the height of the
rectangle to be filled.
drawRect
public void drawRect(int x, int y, int width, int height)
The drawRect
method draws the outline of a rectangle using the current color
and the specified dimensions.
Parameters:
x-the x coordinate of the
rectangle to be drawn.
y-the y coordinate of the
rectangle to be drawn.
width-the width of the rectangle
to be drawn.
height-the height of the
rectangle to be drawn.
clearRect
public abstract void clearRect(int x,
int y, int width, int height)
The clearRect
method clears a rectangle by filling it with the current background
color of the current drawing surface.
Parameters:
x-the x coordinate of the
rectangle to be cleared.
y-the y coordinate of the
rectangle to be cleared.
width-the width of the rectangle
to be cleared.
height-the height of the
rectangle to be cleared.
drawRoundRect
public abstract void drawRoundRect(int
x, int y, int width, int height,
int arcWidth, int arcHeight)
The drawRoundRect method
draws the outline of a rectangle with rounded edges using the
current color and the specified coordinates.
Parameters:
x-the x coordinate of the
rectangle to be drawn.
y-the y coordinate of the
rectangle to be drawn.
width-the width of the rectangle
to be drawn.
height-the height of the
rectangle to be drawn.
arcWidth-the horizontal diameter
of the arc at the four corners.
arcHeight-the vertical diameter
of the arc at the four corners.
fillRoundRect
public abstract void fillRoundRect(int
x, int y, int width, int height, int arcWidth, int arcHeight)
The fillRoundRect
method fills a rectangle with rounded edges using the current
color and the specified coordinates.
Parameters:
x-the x coordinate of the
rectangle to be drawn.
y-the y coordinate of the
rectangle to be drawn.
width-the width of the rectangle
to be drawn.
height-the height of the
rectangle to be drawn.
arcWidth-the horizontal diameter
of the arc at the four corners.
arcHeight-the vertical diameter
of the arc at the four corners.
draw3DRect
public void draw3DRect(int x, int y,
int width, int height, boolean raised)
The draw3Drect
method draws a highlighted 3D rectangle at a default viewing angle.
Parameters:
x-the x coordinate
of the rectangle to be drawn.
y-the y coordinate of the
rectangle to be drawn.
width-the width of the rectangle
to be drawn.
height-the height of the
rectangle to be drawn.
raised-a boolean value determining
whether the rectangle is raised.
fill3DRect
public void fill3DRect(int x, int y,
int width, int height, boolean raised)
The fill3Drect
method fills a highlighted 3D rectangle using the current color
and specified coordinates at a default viewing angle.
Parameters:
x-the x coordinate of the
rectangle to be drawn.
y-the y coordinate of the
rectangle to be drawn.
width-the width of the rectangle
to be drawn.
height-the height of the
rectangle to be drawn.
raised-a boolean value determining
whether the rectangle is raised.
drawOval
public abstract void drawOval(int x,
int y, int width, int height)
The drawOval
method draws the outline of an oval shape using the current color
and the specified coordinates. The oval is drawn inside the rectangle
represented by the input coordinates.
Parameters:
x-the x coordinate of the
rectangle to draw the oval within.
y-the y coordinate of the
rectangle to draw the oval within.
width-the width of the rectangle
to draw the oval within.
height-the height of the
rectangle to draw the oval within.
fillOval
public abstract void fillOval(int x, int y, int width, int height)
The fillOval
method fills an oval using the current color and the specified
coordinates. The oval is drawn inside the rectangle represented
by the input coordinates.
Parameters:
x-the x coordinate of the
rectangle to draw the oval within.
y-the y coordinate of the
rectangle to draw the oval within.
width-the width of the rectangle
to draw the oval within.
height-the height of the
rectangle to draw the oval within.
drawArc
public abstract void drawArc(int x, int
y, int width, int height, int startAngle, int arcAngle)
The drawArc method
draws an arc outline using the current color and bounded by the
specified input coordinates. Note that 0 degrees represents the
three o'clock position and that positive angles are measured going
counterclockwise.
Parameters:
x-the x coordinate of the
rectangle to draw the arc within.
y-the y coordinate of the
rectangle to draw the arc within.
width-the width of the rectangle
to draw the arc within.
height-the height of the
rectangle to draw the arc within.
startAngle-the starting angle
of the arc to be drawn.
arcAngle-the angle of the
arc relative to the start angle.
fillArc
public abstract void fillArc(int x, int
y, int width, int height, int startAngle, int arcAngle)
The fillArc method
fills an arc using the current color and bounded by the specified
input coordinates. Note that 0 degrees represents the three o'clock
position and that positive angles are measured going counterclockwise.
Parameters:
x-the x coordinate
of the rectangle to draw the arc within.
y-the y coordinate of the
rectangle to draw the arc within.
width-the width of the rectangle
to draw the arc within.
height-the height of the
rectangle to draw the arc within.
startAngle-the starting angle
of the arc to be drawn.
arcAngle-the angle of the
arc relative to the start Angle.
drawPolygon
public abstract void drawPolygon(int
xPoints[], int yPoints[], int nPoints)
The drawPolygon
method draws a polygon using the current color and the specified
coordinates.
Parameters:
xPoints-an array
of integers containing the starting x coordinates for each edge
of the polygon.
yPoints-an array of integers
containing the starting y coordinates for each edge of the polygon.
nPoints-an integer value
representing the number of edges of the polygon.
drawPolygon
public void drawPolygon(Polygon p)
This drawPolygon
method draws a polygon using the specified Polygon
class.
Parameters: p-a
Polygon object containing
the coordinates for the polygon to be drawn.
fillPolygon
public abstract void fillPolygon(int
xPoints[], int yPoints[], int nPoints)
The fillPolygon
method fills a polygon using the current color and the specified
coordinates.
Parameters:
xPoints-an array
of integers containing the starting x coordinates for each edge
of the polygon.
yPoints-an array of integers
containing the starting y coordinates for each edge of the polygon.
nPoints-an integer value
representing the number of edges of the polygon.
fillPolygon
public void fillPolygon(Polygon p)
This fillPolygon
method fills a polygon using the specified Polygon
object and the current color.
Parameters: p-a
Polygon object containing
the coordinates for the polygon to be drawn.
drawString
public abstract void drawString(String
str, int x, int y)
The drawString
method will draw a string using the current font at the specified
coordinates.
Parameters:
str-the string to
be displayed.
x-the x coordinate to draw
the string at.
y-the y coordinate to draw
the string at.
drawChars
public void drawChars(char data[], int
offset, int length, int x, int y)
The drawChars
method will draw a string using the current font at the specified
coordinates.
Parameters:
data-an array of
characters.
offset-the offset within
the array of characters that the displayed string will start at.
length-the number of characters
to draw.
x-the x coordinate to draw
the string at.
y-the y coordinate to draw
the string at.
drawBytes
public void drawBytes(byte data[], int
offset, int length, int x, int y)
The drawChars
method will draw a string using the current font at the specified
coordinates.
Parameters:
data-an array of
bytes.
offset-the offset within
the array of bytes that the displayed string will start at.
length-the number of bytes
to draw.
x-the x coordinate to draw
the string at.
y-the y coordinate to draw
the string at.
drawImage
public abstract boolean drawImage(Image
img, int x, int y, ImageObserver observer)
The drawImage
method will draw an image at a specified location.
Parameters:
img-an Image
class to be drawn using the graphics context.
x-the x coordinate to draw
the image at.
y-the y coordinate to draw
the image at.
observer-an ImageObserver
interface that will be used to notify when the drawing is done.
Returns: A boolean value indicating the success/failure
of the draw operation.
drawImage
public abstract boolean drawImage(Image
img, int x, int y, int width,
int height, ImageObserver observer)
This drawImage method will
draw an image at a specified location within the specified bounding
rectangle.
Parameters:
img-an Image
class to be drawn using the graphics context.
x-the x coordinate to draw
the image at.
y-the y coordinate to draw
the image at.
width-the width of the rectangle
to draw the image within.
height-the height of the
rectangle to draw the image within.
observer-an ImageObserver
interface that will be used to notify when the drawing is done.
Returns: A boolean value indicating the success/failure
of the draw operation.
drawImage
public abstract boolean drawImage(Image
img, int x, int y, Color bgcolor,
ImageObserver observer)
This drawImage method will
draw an image at a specified location using the specified background
color.
Parameters:
img-an Image
class to be drawn using the graphics context.
x-the x coordinate to draw
the image at.
y-the y coordinate to draw
the image at.
bgcolor-the background color
to be used.
observer-an ImageObserver
derived object that will be used to notify when the drawing is
done.
Returns: A boolean value indicating the success/failure
of the draw operation.
drawImage
public abstract boolean drawImage(Image
img, int x, int y, int width,
int height, Color bgcolor, ImageObserver observer)
The drawImage method will
draw an image at a specified location within a specified bounding
rectangle using a specified background color.
Parameters:
img-an Image
class to be drawn using the graphics context.
x-the x coordinate to draw
the image at.
y-the y coordinate to draw
the image at.
width-the width of the bounding
rectangle.
height-the height of the
bounding rectangle.
bgcolor-the background color
to be used.
observer-an ImageObserver
interface that will be used to notify when the drawing is done.
Returns: A boolean value indicating the success/failure
of the draw operation.
dispose
public abstract void dispose()
The dispose method
disposes of the Graphics
object.
finalize
public void finalize()
The finalize
method disposes of the Graphics
object once it is no longer referenced.
toString
public String toString()
The toString
method returns a string representation of the Graphics
object.
Returns: A String
containing the Graphics class
name, current color, and current font.
Extends: Object
Implements: Cloneable
A GridBagConstraints class
is used in conjunction with a GridBagLayout
in order to specify the constraints of the objects being laid
out.
Member Constants
public static final int RELATIVE
A public static value representing
the relative constraint.
public static final int REMAINDER
A public static value representing
the remainder constraint.
public static final int NONE
A public static value representing
the none constraint.
public static final int BOTH
A public static value representing
the both constraint.
public static final int HORIZONTAL
A public static value representing
the horizontal constraint.
public static final int VERTICAL
A public static value representing
the vertical constraint.
public static final int CENTER
A public static value representing
the center constraint.
public static final int NORTH
A public static value representing
the north constraint.
public static final int NORTHEAST
A public static value representing
the northeast constraint.
public static final int EAST
A public static value representing
the east constraint.
public static final int SOUTHEAST
A public static value representing
the southeast constraint.
public static final int SOUTH
A public static value representing
the south constraint.
public static final int SOUTHWEST
A public static value representing
the southwest constraint.
public static final int WEST
A public static value representing
the west constraint.
public static final int NORTHWEST
A public static value representing
the northwest constraint.
Member Variables
public int gridx
The gridx variable is used
to store the grid x coordinate.
public int gridy
The gridy variable is used
to store the grid y coordinate.
public int gridwidth
The gridwidth variable is
used to store the grid bounding rectangle width.
public int gridheight
The gridheight variable is
used to store the grid bounding rectangle height.
public double weightx
The weightx variable is used
to store the horizontal space for a component to reserve for itself.
If this is set to 0 (the
default), all components within a row will be bunched together
in the center of the row.
public double weighty
The weighty variable is used
to store the vertical space for a component to reserve for itself.
If this is set to 0 (the
default), all components within a column will be bunched together
in the center of the column.
public int anchor
The anchor variable is used
to determine how to display a component when it is smaller than
its display area. Valid values for this variable are CENTER
(the default), NORTH, NORTHEAST,
EAST, SOUTHEAST,
SOUTH, SOUTHWEST,
WEST, and NORTHWEST.
public int fill
The fill variable is used
to determine how to display a component when it is larger than
its display area. Valid values for this variable are NONE,
HORIZONTAL, VERTICAL,
and BOTH.
public Insets insets
The insets variable is used
to determine the space between the component and its bounding
area.
public int ipadx
The ipadx variable is used
to determine the amount of padding to always add to the component
on its left and right sides.
public int ipady
The ipady variable is used
to determine the amount of padding to always add to the component
on its top and bottom sides.
GridBagConstraints Constructor
public GridBagConstraints ()
The GridBagConstraints
constructor creates a GridBagConstraints
class containing default values.
clone
public Object clone()
The clone method
creates a clone of this GridBagConstraints
object.
Returns: An Object
object representing a clone of this GridBagConstraints
object.
Extends: Object
Implements: LayoutManager
The GridBagLayout
implements the LayoutManager
interface. This class uses a rectangular grid of cells to lay
out components within the cells. Each component is associated
with a GridBagConstraints
object that controls how the component is actually laid out within
the grid.
Member Variables
public int columnWidths[]
The columnWidths variable is an array of integers representing
the widths of each column used by GridBagLayout.
public int rowHeights[]
The rowHeights variable is an array of integers representing
the heights of each column used by GridBagLayout.
public double columnWeights[]
The columnWeights variable is an array of doubles representing
the space to be distributed for each column.
public double rowWeights[]
The rowWeights variable is an array of doubles representing the
space to be distributed for each row.
GridBagLayout Constructor
public GridBagLayout()
The GridBagLayout constructor
constructs a GridBagLayout
class for use in laying out components on a form.
setConstraints
public void setConstraints(Component
comp, GridBagConstraints constraints)
The setConstraints
method sets GridBagConstraints
for the specified component.
Parameters:
comp-a component to be modified
within GridBagLayout.
constraints-the GridBagConstraints
that will be applied to the component.
getConstraints
public GridBagConstraints getConstraints(Component
comp)
The getConstraints
method returns the constraints currently applied to the specified
component.
Parameters: comp-a
component managed by GridBagLayout.
Returns: A GridBagConstraints
class representing the constraints placed upon the specified component.
getLayoutOrigin
public Point getLayoutOrigin ()
The getLayoutOrigin
method returns the origin of the layout manager.
Returns: A Point
class representing the origin of GridBagLayout.
getLayoutDimensions
public int [][] getLayoutDimensions ()
The getLayoutDimensions
method returns an array of dimensions with an element for each
component.
Returns: An array containing layout dimensions for
components managed by the GridBagLayout.
getLayoutWeights
public double [][] getLayoutWeights()
The getLayoutWeights
method returns an array of weights with an element for each component.
Returns: An array containing layout weights for
components managed by GridBagLayout.
location
public Point location(int x, int y)
The location
method returns a Point object
representing the point within the layout manager corresponding
to the specified coordinates.
Parameters:
x-the x coordinate.
y-the y coordinate.
Returns: A Point
object.
addLayoutComponent
public void addLayoutComponent(String
name, Component comp)
The addLayoutComponent
method adds a component to GridBagLayout.
Parameters:
name-the name of the component
to be added.
comp-the component to be
added.
removeLayoutComponent
public void removeLayoutComponent(Component
comp)
The removeLayoutComponent
method removes a component from the GridBagLayout.
Parameters: comp-the
component to be removed.
preferredLayoutSize
public Dimension preferredLayoutSize(Container
parent)
The preferredLayoutSize
method returns the preferred size for the layout manager given
the specified container and the components within it.
Parameters: parent-a
Container object containing
components.
Returns: A Dimension
object specifying the preferred size of the layout manager.
minimumLayoutSize
public Dimension minimumLayoutSize(Container
parent)
The minimum preferredLayoutSize
method returns the minimum size for the layout manager given the
specified container and the components within it.
Parameters: parent-a
Container object containing
components.
Returns: A Dimension
object specifying the minimum size of the layout manager.
layoutContainer
public void layoutContainer(Container
parent)
The layoutContainer
method lays out the specified container within the layout manager.
Parameters: parent-a
Container object containing
components.
toString
public String toString()
The toString
method returns a string containing information about the GridBagLayout.
Returns: A String
containing the name of GridBagLayout.
Extends: Object
Implements: LayoutManager
The GridLayout
class implements the LayoutManager
interface. It is used to lay out grid objects.
GridLayout Constructor
public GridLayout(int rows, int cols)
The GridLayout
constructor constructs a grid layout manager using the specified
number of rows and columns.
Parameters:
rows-the number of rows to
be laid out.
cols-the number of columns
to be laid out.
GridLayout Constructor
public GridLayout(int rows, int cols,
int hgap, int vgap)
This GridLayout
constructor constructs a grid layout manager using the specified
number of rows and columns as well as the horizontal and vertical
gaps to be used.
Parameters:
rows-the number of
rows to be laid out.
cols-the number of columns
to be laid out.
hgap-the horizontal gap value.
vgap-the vertical gap value.
addLayoutComponent
public void addLayoutComponent(String
name, Component comp)
The addLayoutComponent
method adds a component to GridLayout.
Parameters:
name-the name of the component
to be added.
comp-the component to be
added.
removeLayoutComponent
public void removeLayoutComponent(Component
comp)
The removeLayoutComponent
method removes a component from the GridBagLayout.
Parameters: comp-the
component to be removed.
preferredLayoutSize
public Dimension preferredLayoutSize(Container
parent)
The preferredLayoutSize
method returns the preferred size for the layout manager given
the specified container and the components within it.
Parameters: parent-a
Container object containing
components.
Returns: A Dimension
object specifying the preferred size of the layout manager.
minimumLayoutSize
public Dimension minimumLayoutSize(Container
parent)
The minimum preferredLayoutSize
method returns the minimum size for the layout manager given the
specified container and the components within it.
Parameters: parent-a
Container object containing
components.
Returns: A Dimension
object specifying the minimum size of the layout manager.
layoutContainer
public void layoutContainer(Container
parent)
The layoutContainer
method lays out the specified container within the layout manager.
Parameters: parent-a
Container object containing
components.
toString
public String toString()
The toString
method returns a string containing information about the GridLayout.
Returns: A String
containing the grid layout's name,
hgap, vgap,
rows, and cols
values.
Extends: Object
An Image class
is actually an abstract class. A platform-specific implementation
must be provided for it to be used.
getWidth
public abstract int getWidth(ImageObserver
observer)
The getWidth
method returns the width of the image. If the width of the image
is not yet known, ImageObserver
will be notified at a later time and -1
will be returned.
Parameters: observer-an
ImageObserver-derived object
that will be notified if the image is not yet available.
Returns: An integer value representing the width
of the image, or -1 if the
image is not yet available.
getHeight
public abstract int getHeight(ImageObserver
observer)
The getWidth
method returns the height of the image. If the height of the image
is not yet known, ImageObserver
will be notified at a later time and -1
will be returned.
Parameters: observer-an
ImageObserver-derived object
that will be notified if the image is not yet available.
Returns: An integer value representing the height
of the image, or -1 if the
image is not yet available.
getSource
public abstract ImageProducer getSource()
The getSource
method returns the ImageProducer
interface responsible for producing the Image's
pixels.
Returns: An ImageProducer
interface used by the image-filtering classes in package java.awt.Image.
getGraphics
public abstract Graphics getGraphics()
The getGraphics
method is used to return a graphics context for drawing into.
This function is used for offscreen image operations such as double
buffering of an image.
Returns: A Graphics
object used for image-drawing purposes.
getProperty
public abstract Object getProperty(String
name, ImageObserver observer)
The getProperty
method is used to return image property information (each image
type has its own set of properties).
Parameters:
name-the image property name
to be returned.
observer-an ImageObserver-derived
object that will be notified if the image is not yet ready.
Returns: The Property
object that corresponds with the property requested. If the image
is not yet available, this method returns null. If the property
was undefined, an UndefinedProperty
object is returned.
flush
public abstract void flush()
The flush method
flushes all image data. Calling this method returns the image
to its initial empty state; therefore, the image will need to
be re-created after calling this method.
Extends: Object
Implements: Cloneable
The Insets class
encapsulate the insets of a container.
Member Variables
public int top
>
An integer value representing the inset from the top.
public int left
An integer value representing the inset from the left.
public int bottom
An integer value representing the inset from the bottom.
public int right
An integer value representing the inset from the right.
Insets Constructor
public Insets(int top, int left, int
bottom, int right)
This Insets constructor
creates an Insets object
from the specified values.
Parameters:
top-an integer value representing
the inset from the top.
left-an integer value representing
the inset from the left.
bottom-an integer value representing
the inset from the bottom.
right-an integer value representing
the inset from the right.
toString
public String toString()
The toString
method provides a string representation of the Insets
class.
Returns: A String
value containing the Insets's
name, top, left, bottom, and right values.
clone
public Object clone()
The clone method
creates and returns a clone of the Insets
object.
Returns: An Object
class representing a clone of the current Insets.
Extends: Component
A Label is a
component used to display a single line of text on the screen.
Member Constants
public static final int LEFT
A static integer value representing left alignment.
public static final int CENTER
A static integer value representing center alignment.
public static final int RIGHT
A static integer value representing right alignment.
Label Constructor
public Label()
The Label constructor
constructs a label with no string.
Label Constructor
public Label(String label)
This Label constructor
constructs a label using the specified string.
Parameters: label-a
String that will be displayed
as the label.
Label Constructor
public Label(String label, int alignment)
This Label constructor
constructs a label using the specified string and alignment.
Parameters:
label-a String
that will be displayed as the label.
alignment-an alignment value
(CENTER, LEFT,
or RIGHT).
addNotify
public synchronized void addNotify()
The addNotify
method creates the peer interface for the label. Using a peer
interface allows the user interface of the label to be modified
without changing the functionality.
getAlignment
public int getAlignment()
The getAlignment
method returns the label's current alignment.
Returns: An integer value representing the label's
current alignment (LEFT,
RIGHT, or CENTER).
setAlignment
public void setAlignment(int alignment)
The setAlignment
method sets the label's current alignment.
Parameters: alignment-an
integer value representing the label's new alignment (LEFT,
RIGHT, or CENTER).
getText
public String getText()
The getText method
returns the label's current text string.
Returns: A String
value representing the label's current text.
setText
public void setText(String label)
The setText method
sets the label's current text string.
Parameters: label-a
String value representing
the label's new text.
Extends: Component
A List component
is a scrolling list of text items. Lists can allow multiple selection
and visible lines.
List Constructor
public List()
The List constructor
creates a List object with
no lines or multiple selection capability.
List Constructor
public List(int rows, boolean multipleSelections)
This List constructor
constructs a List object
with the specified lines and multiple selection capability.
Parameters:
rows-the number of items
in the list.
multipleSelections-a boolean
value that is true if multiple
selections are allowed, false
if not.
addNotify
public synchronized void addNotify()
The addNotify
method creates the peer interface for the list. Using a peer interface
allows the user interface of the list to be modified without changing
the functionality.
removeNotify
public synchronized void removeNotify()
The removeNotify
method removes the peer for the list.
countItems
public int countItems()
The countItems
method returns the number of items in the list.
Returns: An integer value representing the number
of items in the list.
getItem
public String getItem(int index)
The getItem method
returns the item at the specified list index.
Parameters: index-an
integer value representing the index into the list's string elements.
Returns: The String
value stored at the specified list index.
addItem
public synchronized void addItem(String
item)
The addItem method
adds a String item to the
end of the list.
Parameters: item-a
String item to be added to
the end of the list.
addItem
public synchronized void addItem(String
item, int index)
This addItem
method adds a String item
at the specified index within the list.
Parameters:
item-a String
item to be added to the list.
index-an integer value representing
the index within the list to add the String
to (if this value is -1 or
greater than the number of items within the list, the String
item will be added to the end of the list).
replaceItem
public synchronized void replaceItem(String
newValue, int index)
The replaceItems
method replaces the current item at the specified index with the
new String item.
Parameters:
newValue-a String
value representing the new String
to be used to modify the list.
index-an integer value representing
the index within the list to be replaced with the new string (if
this value is -1 or greater
than the number of items within the list, the String
item will be added to the end of the list).
clear
public synchronized void clear()
The clear method
will clear the list's string of items.
delItem
public synchronized void delItem(int
position)
The delItem method
will delete the String item
stored at the specified position within the list.
Parameters: position-an
integer value representing the position of the string to be deleted.
delItems
public synchronized void delItems(int
start, int end)
The delItems
method will delete a sequence of String
items stored at the specified positions within the list.
Parameters:
start-an integer
value representing the first position containing a string to be
deleted.
end-an integer value representing
the last position containing a string to be deleted.
getSelectedIndex
public synchronized int getSelectedIndex()
The getSelectedIndex
method returns the index of the currently selected position within
the list.
Returns: An integer value representing the currently
selected position within the list.
getSelectedIndexes
public synchronized int[] getSelectedIndexes()
The getSelectedIndexes
method returns an array containing all of the currently selected
positions within the list.
Returns: An array of integers containing the currently
selected positions within the list.
getSelectedItem
public synchronized String getSelectedItem()
The getSelectedItem
method returns the string at the currently selected position within
the list.
Returns: The String
value that is at the currently selected position within the list.
getSelectedItems
public synchronized String[] getSelectedItems()
The getSelectedItems
method returns an array of Strings
that are at the currently selected positions within the list.
Returns: An array of strings that are at the currently
selected positions within the list.
select
public synchronized void select(int index)
The select method
selects the item in the list at the specified index position.
Parameters: index-an
integer value representing the position to be selected within
the list.
deselect
public synchronized void deselect(int
index)
The deselect
method deselects the item in the list at the specified index position.
Parameters: index-an
integer value representing the position to be deselected within
the list.
isSelected
public synchronized boolean isSelected(int
index)
The isSelected
method checks the specified index position to see wether it is
currently selected.
Parameters: index-an
integer value representing the position to be checked within the
list.
Returns: A boolean value that will be true
if the specified index position is slected, false
if not.
getRows
public int getRows()
The getRows method
returns the number of rows within the list.
Returns: An integer value representing the number
of rows currently in the list.
allowsMultipleSelections
public boolean allowsMultipleSelections()
The allowsMultipleSelections
method returns the multiple selection state of the List
object.
Returns: A boolean value that will be true
if multiple selections are allowed, false
if not.
setMultipleSelections
public void setMultipleSelections(boolean
v)
The setMultipleSelections
method sets the multiple selection state of the List
object.
Parameters: v-a
boolean value that will be true
if multiple selections are to be allowed, false
if not.
getVisibleIndex
public int getVisibleIndex()
The getVisibleIndex
method returns the index of the item that was last made visible
by the makeVisible method.
Returns: An integer value representing the index
of the item that was just made visible by the makeVisible
method.
makeVisible
public void makeVisible(int index)
The makeVisible
method forces the list item at the specified index position to
be visible.
Parameters: index-the
index position of the item that is to be made visible.
preferredSize
public Dimension preferredSize(int rows)
The preferredSize
method returns the preferred size of the List
object based on the specified number of rows.
Parameters: rows-the
number of rows used to determine the list's preferred size.
Returns: A Dimension
object representing the preferred size of the list.
preferredSize
public Dimension preferredSize()
This preferredSize
method returns the preferred size of the List
object based on its current number of rows.
Returns: A Dimension
object representing the preferred size of the list.
minimumSize
public Dimension minimumSize(int rows)
The minimumSize
method returns the minimum size of the List
object based on the specified number of rows.
Parameters: rows-the
number of rows used to determine the list's minimum size.
Returns: A Dimension
object representing the minimum size of the list.
minimumSize
public Dimension minimumSize()
This minimumSize
method returns the minimum size of the List
object based on its current number of rows.
Returns: A Dimension
object representing the minimum size of the list.
Extends: Object
The MediaTracker
class is provided to track the status of media objects. At the
current time, only images are supported, but this functionality
could be extended to support audio and video as well.
Member Constants
public static final int LOADING
A static integer value representing the LOADING status.
public static final int ABORTED
A static integer value representing the ABORTED status.
public static final int ERRORED
A static integer value representing the ERRORED status.
public static final int COMPLETE
A static integer value representing the COMPLETE status.
MediaTracker Constructor
public MediaTracker(Component comp)
The MediaTracker
constructor creates a MediaTracker
object to track images for the specified component.
Parameters: comp-a
component that will use a MediaTracker
object to track images.
addImage
public void addImage(Image image, int
id)
The addImage
method will add the specified Image
to the list of images being tracked by the MediaTracker.
The Image will be rendered
at its default size.
Parameters:
image-the Image
object to be added to the list.
id-an identification used
to reference the Image object.
addImage
public synchronized void addImage(Image
image, int id, int w, int h)
This addImage
method will add the specified Image
to the list of images being tracked by the MediaTracker.
The image will be rendered at its specified size.
Parameters:
image-the Image
object to be added to the list.
id-an ID used to reference
the Image object.
w-the width the image will
be rendered at.
h-the height the image will
be rendered at.
checkAll
public boolean checkAll()
The checkAll
method is used to check if all of the images have been loaded.
Returns: A boolean value that is true
if all of the images have been loaded, false
if not.
checkAll
public synchronized boolean checkAll(boolean
load)
This checkAll
method is used to check whether all of the images have been loaded.
The load parameter forces
the MediaTracker to load
any images that are not currently being loaded.
Parameters: load-a
boolean value that, if true,
will force the MediaTracker
to load any images that are not currently being loaded.
Returns: A boolean value that is true
if all of the images have been loaded, false
if not.
isErrorAny
public synchronized boolean isErrorAny()
The isErrorAny
method checks the status of all images being tracked by the MediaTracker.
Returns: A boolean value that will be true
if any image loaded had an error value, false
if not.
getErrorsAny
public synchronized Object[] getErrorsAny()
The getErrorsAny
method checks the status of all images being tracked by the MediaTracker
and returns an array of all media objects that have generated
an error.
Returns: An array of media objects that have encountered
an error. This array will be null if no objects have encountered
an error.
waitForAll
public void waitForAll() throws InterruptedException
The waitForAll
method begins to load all Images
without being interrupted. If there is an error, the InterruptedException
is thrown.
Throws: InterruptedException
if another thread has interrupted this thread.
waitForAll
public synchronized boolean waitForAll(long
ms) throws InterruptedException
This waitForAll
method begins to load all images without being interrupted. This
method will continue to load images until there is an error or
until the specified timeout has elapsed. If there is an error,
the InterruptedException
is thrown.
Parameters: ms-a
long integer value representing the timeout value (in milliseconds)
to wait before halting the loading of images.
Returns: A boolean value that will return true
if all of the images were successfully loaded before timing out,
false if not.
Throws: InterruptedException
if another thread has interrupted this thread.
statusAll
public int statusAll(boolean load)
The statusAll
method returns the boolean OR
of all of the media objects being tracked.
Parameters: load-a
boolean value that specifies whether to start the image loading.
Returns: The boolean OR
of all of the media objects being tracked. This value can be LOADED,
ABORTED, ERRORED,
or COMPLETE.
checkID
public boolean checkID(int id)
The checkID method
checks to see if all images tagged with the specified ID have
been loaded.
Parameters: id-an
integer tag used to identify a media object or objects.
Returns: A boolean value that is true
if all objects with the specified ID have been loaded, false
if not.
checkID
public synchronized boolean checkID(int
id, boolean load)
The checkID method
checks to see whether all images tagged with the specified id
have been loaded. These images will be loaded based on the value
of the load parameter.
Parameters:
id-an integer tag used to
identify a media object or objects.
load-a boolean value that
is true if all objects with
the specified identifier are to be loaded, false
if not.
Returns: A boolean value that is true
if all objects with the specified identifier have been loaded,
false if not.
isErrorID
public synchronized boolean isErrorID(int
id)
The isErrorID
method checks the error status of all media objects with the specified
id.
Parameters: id-an
integer tag used to identify a media object or objects.
Returns: A boolean value that is true
if all objects were loaded without error, false
if not.
getErrorsID
public synchronized Object[] getErrorsID(int
id)
The getErrorsAny
method checks the status of all images being tracked by the MediaTracker
whose id match the specified
id. It returns an array of
all media objects that have generated an error.
Parameters: id-an
integer tag used to identify a media object or objects.
Returns: An array of media objects that have encountered
an error. This array will be null if no objects have encountered
an error.
waitForID
public void waitForID(int id) throws
InterruptedException
The waitForID
method begins to load all images with the specified id
without being interrupted. If there is an error, the InterruptedException
is thrown.
Parameters: id-an
integer tag used to identify a media object or objects.
Throws: InterruptedException
if another thread has interrupted this thread.
waitForID
public synchronized boolean
waitForID(int id, long ms) throws
InterruptedException
This waitForID method begins
to load all images with the specified ID without being interrupted.
This method will continue to load images until there is an error
or until the specified timeout has elapsed. If there is an error,
the InterruptedException
is thrown.
Parameters:
id-an integer tag used to
identify a media object or objects.
ms-a long integer value representing
the timeout value (in milliseconds) to wait before halting the
loading of images.
Returns: A boolean value that will return true
if all of the images were successfully loaded before timing out,
false if not.
Throws: InterruptedException
if another thread has interrupted this thread.
statusID
public int statusID(int id, boolean load)
The statusID
method returns the boolean OR
of all of the media objects being tracked with the specified id.
Parameters:
id-an integer tag used to
identify a media object or objects.
load-a boolean value that
specifies whether to start the image loading.
Returns: The boolean OR
of all the media objects being tracked. This value can be LOADED,
ABORTED, ERRORED,
or COMPLETE.
Extends: MenuItem
Implements: MenuContainer
A Menu is a component
of a menu bar.
Menu Constructor
public Menu(String label)
The Menu constructor
constructs a menu using the specified label string.
Parameters: label-a
String value that will be
displayed as the menu's label.
Menu Constructor
public Menu(String label, boolean tearOff)
This Menu constructor
constructs a menu using the specified label string and tear-off
option.
Parameters:
label-a String
value that will be displayed as the menu's label.
tearOff-a boolean value that
is true if this menu is to
be a tear-off menu, false
if not.
addNotify
public synchronized void addNotify()
The addNotify
method creates the peer interface for the menu. Using a peer interface
allows the user interface of the menu to be modified without changing
the functionality.
removeNotify
public synchronized void removeNotify()
The removeNotify
method removes the peer for the menu.
isTearOff
public boolean isTearOff()
The isTearOff
method returns the tear-off status of the menu.
Returns: A boolean value that will be true
if the menu is a tear-off menu, false
if not.
countItems
public int countItems()
The countItems
method returns the number of items in this menu.
Returns: An integer value representing the number
of items that have been added to this menu.
getItem
public MenuItem getItem(int index)
The getItem method
returns the MenuItem object
at the specified index in the menu list.
Parameters: index-an
integer value representing the position of the menu item to be
returned.
Returns: A MenuItem
object at the specified position.
add
public synchronized MenuItem add(MenuItem
mi)
The add method
adds the specified menu item to the menu's list.
Parameters: mi-the
MenuItem object to be added
to the list.
Returns: A MenuItem
object that was added to the list.
add
public void add(String label)
This add method
adds a MenuItem with the
specified label to the menu.
Parameters: label-a
String value representing
the label to be added to the menu's list.
addSeparator
public void addSeparator()
The addSeparator
method adds a separator menu item to the menu.
remove
public synchronized void remove(int index)
The remove method
removes the menu item at the specified index.
Parameters: index-the
position within the menu's item list to be removed from the list.
remove
public synchronized void remove(MenuComponent
item)
This remove method
removes the menu item specified in the item
parameter.
Parameters: item-the
MenuComponent object to be
removed from the menu's item list.
Extends: MenuComponent
Implements: MenuContainer
A MenuBar object
represents a menu bar on a frame. A MenuBar
object attaches to a Frame
object using the method Frame.setMenuBar.
MenuBar Constructor
public MenuBar()
The MenuBar constructor
constructs an empty MenuBar
object.
addNotify
public synchronized void addNotify()
The addNotify
method creates the peer interface for the menu bar. Using a peer
interface allows the user interface of the menu bar to be modified
without changing the functionality.
removeNotify
public synchronized void removeNotify()
The removeNotify
method removes the peer for the menu bar.
getHelpMenu
public Menu getHelpMenu()
The getHelpMenu
method returns the help menu on the menu bar.
Returns: A Menu
object representing the menu bar's help menu.
setHelpMenu
public synchronized void setHelpMenu(Menu
m)
The setHelpMenu
method sets the help menu for the menu bar.
Parameters: m-a
Menu object representing
the menu bar's help menu.
add
public synchronized Menu add(Menu m)
The add method
adds the specified menu to the menu bar.
Parameters: m-a
Menu object that is to be
added to the menu bar.
Returns: The Menu
object that was added to the menu bar.
remove
public synchronized void remove(int index)
The remove method
removes the menu located at the specified index on the menu bar.
Parameters: index-the
position of the menu to be removed within the menu bar's list
of menus.
remove
public synchronized void remove(MenuComponent
m)
This remove method
removes the specified menu component from the menu bar.
Parameters: m-a
MenuComponent object to be
removed from the menu bar.
countMenus
public int countMenus()
The countMenus
method returns the number of menus located on this menu bar.
Returns: An integer value representing the number
of menus located on this menu bar.
getMenu
public Menu getMenu(int i)
The getMenu method
returns the Menu object at
the specified location within the menu bar's list of menus.
Parameters: i-an
integer value representing the position of the menu to be retrieved
from the menu bar's list.
Returns: A Menu
object returned from the menu bar's list.
Extends: Object
The MenuComponent
class serves as the base class for all menu-type components such
as Menu, MenuBar,
and MenuItem.
getParent
public MenuContainer getParent()
The getParent
method returns the parent menu container of the menu component.
Returns: A MenuContainer
object that is the parent of the menu component.
getPeer
public MenuComponentPeer getPeer()
The getPeer method
returns the MenuComponentPeer
interface for the MenuComponent
object. The MenuComponentPeer
interface allows the user interface of a MenuComponent
to be changed without changing its functionality.
Returns: A MenuComponentPeer
interface.
getFont
public Font getFont()
The getFont method
returns the current default font for the MenuComponent.
Returns: A Font
object.
setFont
public void setFont(Font f)
The setFont method
is used to set the display font for the MenuComponent.
Parameters: f-the
Font object representing
the menu component's new font.
removeNotify
public void removeNotify()
The removeNotify
removes the peer for this menu component.
postEvent
public boolean postEvent(Event evt)
The postEvent
method posts the specified event to the menu component.
Parameters: evt-the
Event object containing the
current event that applies to the menu component.
toString
public String toString()
The toString
method returns a string representation of the MenuComponent
object.
Returns: A String
containing the menu component's name.
Extends: MenuComponent
A MenuItem represents
a choice in a menu.
MenuItem Constructor
public MenuItem(String label)
The MenuItem
constructor constructs a menu item using the specified label string.
Parameters: label-the
String that will be displayed
as the menu item's label.
addNotify
public synchronized void addNotify()
The addNotify
method creates the peer interface for the menu item. Using a peer
interface allows the user interface of the menu item to be modified
without changing the functionality.
getLabel
public String getLabel()
The getLabel
method returns the label string for the menu item.
Returns: A String
value representing the menu item's displayed label.
setLabel
public void setLabel(String label)
The setLabel
method is used to change the string label of the menu item.
Parameters: label-a
String value representing
the menu item's displayed label.
isEnabled
public boolean isEnabled()
The isEnabled
method can be called to determine whether the menu item is enabled.
Returns: A boolean value that will be true
if the menu item is enabled, false
if not.
enable
public void enable()
The enable method
enables the menu item.
enable
public void enable(boolean cond)
This enable method
enables the menu item based on the specified condition.
Parameters: cond-a
boolean value that will conditionally enable the menu item.
disable
public void disable()
The disable method
disables the menu item, making it unselectable by the user.
paramString
public String paramString()
The paramString
method returns a string representation of the menu item.
Returns: A String
value containing the menu item's label string.
Extends: Container
The Panel class represents
a generic container for graphical elements.
Panel Constructor
public Panel()
The Panel constructor
constructs a default Panel
object that will use the FlowLayout
layout manager.
addNotify
public synchronized void addNotify()
The addNotify
method creates the peer interface for the panel. Using a peer
interface allows the user interface of the panel to be modified
without changing the functionality.
Extends: Object
A Point class
encapsulates an x,y coordinate.
Member Variables
public int x
The x variable represents
the x coordinate of the point.
public int y
The y variable represents
the y coordinate of the point.
Point Constructor
public Point(int x, int y)
The Point constructor
constructs a Point object
using the specified coordinates.
Parameters:
x-the x coordinate
of the point.
y-the y coordinate of the
point.
move
public void move(int x, int y)
The move method
moves the point to the new specified coordinates.
Parameters:
x-the new x coordinate
of the point.
y-the new y coordinate of
the point.
translate
public void translate(int x, int y)
The translate
method translates the point by the specified coordinates.
Parameters:
x-the x amount to
transfer the point.
y-the y amount to transfer
the point.
hashCode
public int hashCode()
The hashCode
method returns a hash code for the point.
Returns: An integer value that represents the point's
hash code.
equals
public boolean equals(Object obj)
The equals method
compares the Point object
to the specified object.
Parameters: obj-the
object to compare the point to.
Returns: A boolean value representing the result
of the comparison (true or
false).
toString
public String toString()
The toString
method returns a string representation of the Point
object.
Returns: A String
containing the point's name and x and y values.
Extends: Object
A Polygon contains
a list of x,y coordinates, unlike a Point
class, which contains only one coordinate set.
Member Variables
public int npoints
The npoint variable represents the total number of points within
the Polygon.
public int xpoints[]
The xpoints variable is an integer array of all of the
x coordinate points.
public int ypoints[]
The ypoints variable is an integer array of all of the y coordinate
points.
Polygon Constructor
public Polygon()
The Polygon constructor
constructs an empty Polygon
object.
Polygon
public Polygon(int xpoints[],
int ypoints[], int npoints)
This Polygon constructor
constructs a Polygon object
using the specified coordinates.
Parameters:
xpoints-an array of integers
representing the x coordinate points of the polygon.
ypoints-an array of integers
representing the y coordinate points of the polygon.
npoints-an integer value
representing the number of points in the polygon.
addPoint
public void addPoint(int x, int y)
The addPoint
method adds a point to the polygon.
Parameters:
x-the x coordinate of the
point to be added.
y-the y coordinate of the
point to be added.
getBoundingBox
public Rectangle getBoundingBox()
The getBoundingBox
returns the rectangular bounding box for the polygon.
Returns: A Rectangle
object representing the bounding box for the polygon.
inside
public boolean inside(int x, int y)
The inside method
determines whether the specified coordinates are inside the polygon's
bounding rectangle.
Parameters:
x-the x coordinate to check.
y-the y coordinate to check.
Returns: A boolean value that is true
if the coordinates are inside the polygon's bounding rectangle,
false if not.
Extends: Object
A Rectangle class
specifies the dimensions of a rectangle using x,
y, height,
and width values.
Member Variables
public int x
The x variable stores the rectangle's x coordinate.
public int y
The y variable stores the rectangle's y coordinate.
public int width
The width variable stores the rectangle's width.
public int height
The height variable stores the rectangle's height.
Rectangle Constructor
public Rectangle()
The Rectangle
constructor constructs a rectangle of zero size.
Rectangle Constructor
public Rectangle(int x, int y, int width,
int height)
This Rectangle
constructor constructs a rectangle using the specified coordinates.
Parameters:
x-the x coordinate of the
rectangle.
y-the y coordinate of the
rectangle.
width-the width of the rectangle.
height-the height of the
rectangle.
Rectangle Constructor
public Rectangle(int width, int height)
This Rectangle
constructor constructs a rectangle using the specified width and
height.
Parameters:
width-the width of the rectangle.
height-the height of the
rectangle.
Rectangle Constructor
public Rectangle(Point p, Dimension d)
This Rectangle
constructor constructs a rectangle using the specified coordinates
and size.
Parameters:
p-a Point
object containing the rectangle's x and y coordinates.
d-a Dimension
object containing the rectangle's size.
Rectangle Constructor
public Rectangle(Point p)
This Rectangle
constructor constructs a rectangle using the specified point.
Parameters: p-a
Point object containing the
rectangle's x and y coordinates.
Rectangle Constructor
public Rectangle(Dimension d)
This Rectangle
constructor constructs a rectangle using the specified Dimension.
Parameters: d-a
Dimension object containing
the rectangle's size.
reshape
public void reshape(int x, int y, int
width, int height)
The reshape method
resizes the rectangle's coordinates and size.
Parameters:
x-the x coordinate of the
rectangle.
y-the y coordinate of the
rectangle.
width-the width of the rectangle.
height-the height of the
rectangle.
move
public void move(int x, int y)
The move method
moves the rectangle to the specified coordinates.
Parameters:
x-the x coordinate of the
rectangle.
y-the y coordinate of the
rectangle.
translate
public void translate(int x, int y)
The translate
method translates the rectangle by the specified coordinates.
Parameters:
x-the x translation amount
of the rectangle's coordinates.
y-the y translation amount
of the rectangle's coordinates.
resize
public void resize(int width, int height)
The resize method
changes the rectangle's size to the specified parameters.
Parameters:
width-the width of
the rectangle.
height-the height of the
rectangle.
inside
public boolean inside(int x, int y)
The inside method
determines whether the specified coordinates are inside the rectangle's
bounding rectangle.
Parameters:
x-the x coordinate to be
checked.
y-the y coordinate to be
checked.
Returns: A boolean value that is true
if the coordinates are within the bounding rectangle, false
if not.
intersects
public boolean intersects(Rectangle r)
The intersects
method determines whether the specified rectangle intersects the
rectangle's bounding rectangle.
Parameters: r-a
Rectangle object to be checked
for intersection with the rectangle.
Returns: A boolean value that is true
if the objects intersect, false
if not.
intersection
public Rectangle intersection(Rectangle
r)
The intersection
computes the intersection rectangle (if any) of the two rectangles.
Parameters: r-a
Rectangle object to be tested
for intersection with the rectangle.
Returns: A Rectangle
object that is the intersection of the two Rectangle
objects.
union
public Rectangle union(Rectangle r)
The union method
returns the union of the two rectangles.
Parameters: r-a
Rectangle object that will
be used to determine the union rectangle.
Returns: A Rectangle
object representing the union of the two rectangles.
add
public void add(int newx, int newy)
The add method
adds a new point to the rectangle using the specified coordinates.
This results in the smallest possible rectangle that contains
the current rectangle and the coordinates.
Parameters:
newx-an integer value representing
the x coordinate of the point.
newy-an integer value representing
the y coordinate of the point.
add
public void add(Point pt)
This add method
adds a new point to the rectangle using the specified Point
object. This results in the smallest possible rectangle that contains
the current rectangle and the point's coordinates.
Parameters: pt-a
Point object representing
the point's coordinates.
add
public void add(Rectangle r)
This add method
adds a new rectangle to the existing rectangle. This results in
the union of the two rectangles (current and new).
Parameters: r-a
Rectangle object that will
be used to perform a union with the rectangle.
grow
public void grow(int h, int v)
The grow method
grows the Rectangle object
by the specified horizontal and vertical amounts. The x and y
coordinates will be shifted by the specified amounts, and the
height and width sizes will also be increased by the specified
amounts.
Parameters:
h-an integer amount representing
the amount to grow the rectangle by in the horizontal direction.
v-an integer amount representing
the amount to grow the rectangle by in the vertical direction.
isEmpty
public boolean isEmpty()
The isEmpty method
is used to determine whether the rectangle's width and height
are less than or equal to zero.
Returns: A boolean value that will be true
if the rectangle is empty, false
if not.
hashCode
public int hashCode()
The hashCode
method returns the hash code for the rectangle.
Parameters: An integer value representing the rectangle's
hash code.
equals
public boolean equals(Object obj)
The equals method
compares the specified object with the rectangle.
Parameters: obj-an
object to be compared with the rectangle.
Returns: A boolean value that is true
if the two objects are equal, false
if they are not.
toString
public String toString()
The toString
method returns a String representation
of the rectangle's contents.
Returns: A String
containing the rectangle's name, x,
y, height,
and width values.
Extends: Component
A Scrollbar component
can be added to a frame or other object to provide scrolling capabilities.
Member Constants
public static final int HORIZONTAL
The HORIZONTAL
static int value represents
the horizontal scrollbar orientation variable.
public static final int VERTICAL
The VERTICAL
static int value represents
the vertical scrollbar orientation variable.
Scrollbar Constructor
public Scrollbar()
The Scrollbar
constructor constructs a default scrollbar.
Scrollbar Constructor
public Scrollbar(int orientation)
This Scrollbar
constructor constructs a scrollbar with the specified orientation.
Parameters: orientation-an
integer value that can be either HORIZONTAL
or VERTICAL.
Scrollbar Constructor
public Scrollbar(int orientation,
int value, int visible, int minimum,
int maximum)
This Scrollbar constructor
constructs a complete scrollbar using the specified orientation
and properties.
Parameters:
orientation-an integer value
that can be either HORIZONTAL
or VERTICAL.
value-an integer value representing
the scrollbar's value.
visible-an integer value
representing the size of the scrollbar's visible portion.
minimum-an integer value
representing the scrollbar's minimum value.
maximum-an integer value
representing the scrollbar's maximum value.
addNotify
public synchronized void addNotify()
The addNotify
method creates the peer interface for the scrollbar. Using a peer
interface allows the user interface of the scrollbar to be modified
without changing the functionality.
getOrientation
public int getOrientation()
The getOrientation
method returns the orientation value of the scrollbar.
Returns: An integer value that can be either HORIZONTAL
or VERTICAL.
getValue
public int getValue()
The getValue
method returns the current value of the scrollbar.
Returns: An integer value representing the value
of the scrollbar.
setValue
public void setValue(int value)
The setValue
method set the value of the scrollbar to the specified value.
Parameters: value-An
integer value representing the new value of the scrollbar.
getMinimum
public int getMinimum()
The getMinimum
method returns the minimum value of the scrollbar.
Returns: An integer value representing the scrollbar's
minimum value.
getMaximum
public int getMaximum()
The getMaximum
method returns the maximum value of the scrollbar.
Returns: An integer value representing the scrollbar's
maximum value.
getVisible
public int getVisible()
The getVisible
portion returns the visible amount of the scrollbar.
Returns: An integer value representing the scrollbar's
visible amount.
setLineIncrement
public void setLineIncrement(int l)
The setLineIncrement
method sets the line increment for the scrollbar.
Parameters: l-an
integer value representing the line increment for the scrollbar,
which is the amount that the scrollbar's position increases or
decreases when the user clicks its up or down widgets.
getLineIncrement
public int getLineIncrement()
The getLineIncrement
method returns the line increment for the scrollbar.
Returns: An integer value representing the line
increment for the scrollbar, which is the amount that the scrollbar's
position increases or decreases when the user clicks its up or
down widgets.
setPageIncrement
public void setPageIncrement(int l)
The setPageIncrement
method sets the page increment for the scrollbar.
Parameters: l-an
integer value representing the page increment for the scrollbar,
which is the amount that the scrollbar's position increases or
decreases when the user clicks its page up or page down widgets.
getPageIncrement
public int getPageIncrement()
The getPageIncrement
method returns the page increment for the scrollbar.
Returns: An integer value representing the page
increment for the scrollbar, which is the amount that the scrollbar's
position increases or decreases when the user clicks its page
up or page down widgets.
setValues
public void setValues(int value, int
visible, int minimum, int maximum)
The setValues
method sets the scrollbar's properties based on the specified
values.
Parameters:
value-an integer
value representing the current value of the scrollbar.
visible-an integer value
representing the visible amount of the scrollbar.
minimum-an integer value
representing the scrollbar's minimum value.
maximum-an integer value
representing the scrollbar's maximum value.
Extends: TextComponent
A TextArea class represents
a multiline component that can be used for text display or editing.
TextArea Constructor
public TextArea()
The TextArea
constructor constructs a TextArea
object.
TextArea
public TextArea(int rows, int cols)
This TextArea
constructor constructs a TextArea
object using the specified row and column values.
Parameters:
rows-an integer value specifying
the number of rows to use.
cols-an integer value specifying
the number of columns to use.
TextArea Constructor
public TextArea(String text)
This TextArea
constructor constructs a TextArea
object using the specified text.
Parameters: text-a
String value containing the
text to be displayed in the text area.
TextArea Constructor
public TextArea(String text, int rows,
int cols)
This TextArea
constructor constructs a TextArea
object using the specified row, column, and text values.
Parameters:
text-a String
value containing the text to be displayed in the text area.
rows-an integer value specifying
the number of rows to use.
cols-an integer value specifying
the number of columns to use.
addNotify
public synchronized void addNotify()
The addNotify
method creates the peer interface for the text area. Using a peer
interface allows the user interface of the text area to be modified
without changing the functionality.
insertText
public void insertText(String str, int
pos)
The insertText
method inserts a text string into the text area's text at the
specified position.
Parameters:
str-a String
value containing the text to be inserted in the text area.
pos-an integer value specifying
the position to insert the text string into.
appendText
public void appendText(String str)
The appendText
method appends a text string onto the text area's text.
Parameters: str-a
String value containing the
text to be appended in the text area.
replaceText
public void replaceText(String str, int
start, int end)
The replaceText
method replaces a section of the text area's text at the specified
positions with the specified text string.
Parameters:
str-a String
value containing the text that will replace the text area's current
text.
start-the starting position
of the text to be replaced within the text area.
end-the ending position of
the text to be replaced within the text area.
getRows
public int getRows()
The getRows method
returns the number of rows within the text area.
Returns: An integer value representing the number
of rows within the text area.
getColumns
public int getColumns()
The getColumns
method returns the number of columns within the text area.
Returns: An integer value representing the number
of rows within the text area.
preferredSize
public Dimension preferredSize(int rows,
int cols)
The preferredSize
method returns the preferred size of a text area comprising the
specified rows and columns.
Parameters:
rows-the number of
rows in the text area.
cols-the number of columns
in the text area.
Returns: A Dimension
object representing the preferred size of the specified text area.
preferredSize
public Dimension preferredSize()
This preferredSize
method returns the preferred size dimension of a TextArea
object.
Returns: A Dimension
object representing the preferred size of a text area.
minimumSize
public Dimension minimumSize(int rows,
int cols)
The minimumSize
method returns the minimum size of a text area comprised of the
specified rows and columns.
Parameters:
rows-the number of rows in
the text area.
cols-the number of columns
in the text area.
Returns: A Dimension
object representing the minimum size of the specified text area.
minimumSize
public Dimension minimumSize()
This minimumSize
method returns the minimum size dimension of a TextArea
object.
Returns: A Dimension
object representing the minimum size of a text area.
Extends: Component
The TextComponent
class is a component that provides some text for display or editing.
It serves as the base class for the TextArea
and TextField classes.
removeNotify
public synchronized void removeNotify()
The removeNotify
method removes the text component's peer interface. A peer interface
can be used to modify the text component's user interface without
changing its functionality.
setText
public void setText(String t)
The setText method
sets the text component's displayed text to the specified String
value.
Parameters: t-a
String value representing
the string to be stored in the text component's text value.
getText
public String getText()
The getText method
returns the text component's text value.
Returns: A String
value representing the text component's text value.
getSelectedText
public String getSelectedText()
The getSelectedText
method returns the selected text contained in this text component.
Returns: A String
value representing the text component's text value.
isEditable
public boolean isEditable()
The isEditable
method is used to determine whether the text component's text
can be edited.
Returns: A boolean value that is true
if the text can be edited, false
if not.
setEditable
public void setEditable(boolean t)
The setEditable
method is used to set the text component's edit property.
Parameters: t-a
boolean value that is true
if the text can be edited, false
if not.
getSelectionStart
public int getSelectionStart()
The getSelectionStart
method returns the starting position of the selected text in the
text component.
Returns: An integer value representing the position
of the first selected character in the text component.
getSelectionEnd
public int getSelectionEnd()
The getSelectionEnd
method returns the ending position of the selected text in the
text component.
Returns: An integer value representing the position
of the last selected character in the text component.
select
public void select(int selStart, int
selEnd)
The select method
selects a portion of the text component's text based on the specified
position.
Parameters:
selStart-an integer value
representing the position of the first character to be selected
in the text component.
selEnd-an integer value representing
the position of the last character to be selected in the text
component.
selectAll
public void selectAll()
The selectAll
method selects all of the text component's text.
Extends: TextComponent
The TextField class provides
a single line of text for display or editing.
TextField Constructor
public TextField()
The TextField
constructor constructs a text field of default size.
TextField Constructor
public TextField(int cols)
This TextField
constructor constructs a text field using the specified column
size.
Parameters: cols-the
number of characters that can be entered into the text field.
TextField Constructor
public TextField(String text)
This TextField
constructor constructs a text field using the specified input
string.
Parameters: text-the
default text to be displayed within the text field.
TextField Constructor
public TextField(String text, int cols)
This TextField
constructor constructs a text field using the specified input
string and column values.
Parameters:
text-the default text to
be displayed within the text field.
Cols-the number of columns
to display.
addNotify
public synchronized void addNotify()
The addNotify
method creates the peer interface for the text field. Using a
peer interface allows the user interface of the text field to
be modified without changing the functionality.
getEchoChar
public char getEchoChar()
The getEchoChar
method retrieves the character that will be used for echoing.
Returns: A character value that represents the character
that will be used for echoing.
echoCharIsSet
public boolean echoCharIsSet()
The echoCharIsSet
method is used to determine whether the echo character has been
set.
Returns: A boolean value that is true
if the echo character has been set, false
if not.
getColumns
public int getColumns()
The getColumns
method returns the number of columns used in the display area
of this text field.
Returns: An integer value representing the number
of columns (characters) that will be displayed by the text field.
setEchoCharacter
public void setEchoCharacter(char c)
The setEchoCharacter
method is used to set the character that will be used for echoing.
Echoing is often used on password fields so that the actual characters
entered won't be echoed to the screen.
Parameters: c-a
character value representing the character to be echoed to the
screen.
preferredSize
public Dimension preferredSize(int cols)
This preferredSize
method returns the preferred size dimension of a text field object.
Returns: A Dimension
object representing the preferred size of a text field.
minimumSize
public Dimension minimumSize(int cols)
The minimumSize
method returns the minimum size of a text field comprised of the
specified number of columns.
Parameters: cols-the
number of columns in the text field.
Returns: A Dimension
object representing the minimum size of the specified text field.
minimumSize
public Dimension minimumSize()
This minimumSize
method returns the minimum size dimension of a TextField
object.
Returns: A Dimension
object representing the minimum size of a text field.
Extends: Object
The Toolkit class
is used to bind a native toolkit to the awt classes.
getScreenSize
public abstract Dimension getScreenSize()
The getScreenSize
method returns the size of the screen.
Returns: A Dimension
object containing the size of the screen.
getScreenResolution
public abstract int getScreenResolution()
The getScreenResolution
method returns the current screen resolution in units of dots
per inch.
Returns: An integer value representing the current
screen resolution in dots per inch.
getColorModel
public abstract ColorModel getColorModel()
The getColorModel
method returns the current color model being used.
Returns: A ColorModel
object representing the current color model.
getFontList
public abstract String[] getFontList()
The getFontList
method returns a list of the fonts available.
Returns: An array of strings containing the names
of all fonts available to the system.
getFontMetrics
public abstract FontMetrics getFontMetrics(Font
font)
The getFontMetrics
method returns the font metrics for a specified font.
Parameters: A Font
object.
Returns: A FontMetrics
object containing information on the specified font.
sync
public abstract void sync()
The sync method
syncs the graphics state. This is useful when doing animation.
getDefaultToolkit
public static synchronized Toolkit getDefaultToolkit()
The getDefaultToolkit
method returns a Toolkit
object that is used as the default toolkit.
Returns: A Toolkit
object representing the default system toolkit.
getImage
public abstract Image getImage(String
filename)
The getImage
method returns an Image object
that corresponds with the specified Image
filename.
Parameters: filename-a
String value containing the
filename of the image to be loaded.
Returns: An Image
object.
getImage
public abstract Image getImage(URL url)
The getImage
method retrieves an Image
object that corresponds with the specified URL.
Parameters: url-the
uniform resource locator (URL) of the specified image object.
Returns: An Image
object.
prepareImage
public abstract boolean prepareImage(Image
image, int width, int height,
ImageObserver observer)
The prepareImage
method prepares an image for rendering on the screen based on
the specified image sizes.
Parameters:
image-an Image
object.
width-an integer value representing
the width of the image when displayed.
height-an integer value representing
the height of the image when displayed.
observer-an ImageObserver
object that will be notified when the image is prepared.
Returns: A boolean value that is true
if the image was prepared successfully, false
if not.
checkImage
public abstract int checkImage(Image
image, int width, int height,
ImageObserver observer)
The checkImage method checks
the status of the image construction.
Parameters:
image-an Image
object.
width-an integer value representing
the width of the image when displayed.
height-an integer value representing
the height of the image when displayed.
observer-an ImageObserver
object that will be notified when the image is prepared.
Returns: An integer value representing the status
of the image construction.
createImage
public abstract Image createImage(ImageProducer
producer)
The createImage
method creates an image using the ImageProducer
interface.
Parameters: producer-an
ImageProducer object that
will be notified when the image is prepared.
Returns: An Image
object.
Extends: Container
The Window class is defined
as a top-level window with no borders and no menu bar.
Window Constructor
public Window(Frame parent)
The Window constructor
constructs a window whose parent is specified by the parent
parameter. This window will be invisible after creation and will
act as a modal dialog when initially shown.
Parameters: parent-a
Frame object that is the
parent of this window.
addNotify
public synchronized void addNotify()
The addNotify
method creates the peer interface for the window. Using a peer
interface allows the user interface of the window to be modified
without changing the functionality.
pack
public synchronized void pack()
The pack method
packs the components within the window based on the components'
preferred sizes.
show
public void show()
The show method
shows the window after it has been constructed. If the window
is already visible, the show
method will bring the window to the front.
dispose
public synchronized void dispose()
The dispose method
disposes of the window and all of its contents. This method must
be called to release the window's resources.
toFront
public void toFront()
The toFront method
brings the parent frame to the front of the window.
toBack
public void toBack()
The toBack method
sends the parent frame to the back of the window.
getToolkit
public Toolkit getToolkit()
The getToolkit
method returns the current toolkit for the window.
Returns: A Toolkit
object.
getWarningString
public final String getWarningString()
The getWarningString
method returns a string that is used to warn users. This string
typically displays a security warning and is displayed in an area
of the window visible to users.
Returns: A String
value containing a warning string for users to read.
Extends: Exception
The awtException class is
used to signal that an awt exception has occurred.
Extends: Error
The awtError encapsulates
an awt error.
|