Skip to main content.

Web Based Programming Tutorials

Homepage | Forum - Join the forum to discuss anything related to programming! | Programming Resources

Java Developer's Reference

Chapter 30 -- Package java.awt.peer

Chapter 30

Package java.awt.peer


CONTENTS




The java.awt.peer package is interesting in that it contains no classes. Every object defined within the java.awt.peer package is an interface. By examining the contents of the classes in the java.awt package, you will find that all of the GUI components in that package implement the interfaces found in the java.awt.peer package. The remainder of this chapter lists the interfaces found within the java.awt.peer package and these interfaces' methods. Table 30.1 shows the contents of the java.awt.peer package, and Figure 30.1 shows the hierarchy of the contents of the package.

Figure 30.1: Cotents of package java.awt.peer.

Note
Nearly all of the methods defined in the java.awt.peer interfaces are friendly methods. This means that they can only be accessed from within java.awt package classes. Therefore, if you are developing a class for a package outside of java.awt (which you probably are), these interfaces are not accessible. They are only provided to give some insight into java.awt class functionality.

Table 30.1. Contents of package java.awt.peer.

Interface index
ButtonPeer FileDialogPeer MenuPeer
CanvasPeer FramePeer PanelPeer
CheckboxMenuItemPeer LabelPeer ScrollbarPeer
CheckboxPeer ListPeer TextAreaPeer
ChoicePeer MenuBarPeer TextComponentPeer
ComponentPeer MenuComponentPeer TextFieldPeer
ContainerPeer MenuItemPeer WindowPeer
DialogPeer   

ButtonPeer

ComponentPeer

The ButtonPeer interface extends interface java.awt.peer.ComponentPeer. The ButtonPeer interface provides the basic structure required for button component functionality.

Listing 30.1 shows the declarations for all of the public methods included in the java.awt.peer.ButtonPeer interface.


Listing 30.1. Members of java.awt.peer.ButtonPeer.
public interface ButtonPeer extends ComponentPeer {
  void setLabel(String label)
}

setLabel

ButtonPeer

void setLabel(String label)

The setLabel() method should set the displayed label for the Button using the specified label string.

Label is a String that will be displayed as the button's label.

CanvasPeer

ComponentPeer

The CanvasPeer interface extends interface java.awt.peer.ComponentPeer. The CanvasPeer interface provides the basic structure required for canvas component functionality.



Listing 30.2 shows the declarations for all of the public methods included in the java.awt.peer.ComponentPeer interface.


Listing 30.2. Members of java.awt.peer.CanvasPeer.
public interface CanvasPeer extends ComponentPeer {
}

CheckboxMenuItemPeer

MenuItemPeer

The CheckboxMenuItemPeer interface extends interface java.awt.peer.MenuItemPeer. The CheckboxMenuItemPeer interface provides the basic structure required for CheckboxMenuItem component functionality.

Listing 30.3 shows the declarations for all of the public methods included in the java.awt.peer.CheckboxMenuItemPeer interface.


Listing 30.3. Members of java.awt.peer.CheckboxMenuItemPeer.
public interface CheckboxMenuItemPeer extends MenuItemPeer {
 
 void setState(boolean t)
}

setState

CheckboxMenuItemPeer

void setState(boolean t)

The setState() method sets the checked state of a CheckboxMenuItem.

t is a Boolean value that will be true if the Checkbox is to be checked, false if not.

CheckboxPeer

ComponentPeer

The CheckboxPeer interface extends interface java.awt.peer.ComponentPeer. The CheckboxPeer interface provides the basic structure required for checkbox component functionality.

Listing 30.4 shows the declarations for all of the public methods included in the java.awt.peer.CheckboxPeer interface.


Listing 30.4. Members of java.awt.peer.CheckboxPeer.
public interface CheckboxPeer extends ComponentPeer {
  void setState(boolean state)
  void setCheckboxGroup(CheckboxGroup g)
  void setLabel(String label)
}

setState

CheckboxPeer

void setState(boolean state)

The setState() method sets the checked state of a Checkbox.

t is a Boolean value that should be set to true if the Checkbox is to be checked, false if not.

SetCheckboxGroup

CheckboxPeer

void setCheckboxGroup(CheckboxGroup g)

The setCheckboxGroup() method should set which checkbox group the checkbox belongs to using the specified CheckboxGroup.

g is a CheckboxGroup object of which this Checkbox will be a member.

setLabel

CheckboxPeer

void setLabel(String label)

The setLabel() method should set the displayed label for the Checkbox using the specified label string.

label is a String that will be displayed as the checkbox's label.

ChoicePeer

ComponentPeer

The ChoicePeer interface extends interface java.awt.peer.ComponentPeer. The ChoicePeer interface provides the basic structure required for Choice component functionality.

Listing 30.5 shows the declarations for all of the public methods included in the java.awt.peer.ChoicePeer interface.


Listing 30.5. Members of java.awt.peer.ChoicePeer.
public interface ChoicePeer extends ComponentPeer {
  void addItem(String item, int index)
  void select(int index)
}

addItem

ChoicePeer

void addItem(String item, int index)

The addItem() method adds the specified item to the Choice list at the specified list index.

item is a String value representing the item to be added to the Choice list.

index is the integer index into the Choice list where the item parameter is to be added.

select

ChoicePeer

void select(int index)

The select() method selects the Choice list item at the specified index.

index is the index into the Choice list to be selected.

ComponentPeer

Object

The ComponentPeer interface extends class java.lang.Object. The ComponentPeer interface provides the basic structure required for component functionality.

Listing 30.6 shows the declarations for all of the public methods included in the java.awt.peer.ComponentPeer interface.


Listing 30.6. Members of java.awt.peer.ComponentPeer.
public interface ComponentPeer {
  void                show()
  void                hide()
  void                enable()
  void                disable()
  void                paint(Graphics g)
  void                repaint(long tm, int x, int y, int width, int height)
  void                print(Graphics g)
  void                reshape(int x, int y, int width, int height)
  boolean             handleEvent(Event e)
  Dimension           minimumSize()
  Dimension           preferredSize()
  ColorModel          getColorModel()
  java.awt.Toolkit    getToolkit()
  Graphics            getGraphics()
  FontMetrics         getFontMetrics(Font font)
  void                dispose()
  void                setForeground(Color c)
  void                setBackground(Color c)
  void                setFont(Font f)
  void                requestFocus()
  void                nextFocus()
  Image               createImage(ImageProducer producer)
  Image               createImage(int width, int height)
  boolean             prepareImage(Image img, int w, int h, ImageObserver o)
  int                 checkImage(Image img, int w, int h, ImageObserver o)
}

show

ComponentPeer

void show()

The show() method should be implemented to make the Component object visible.

None

hide

ComponentPeer

void hide()

The hide() method should hide the component so that is not visible.

None

enable

ComponentPeer

void enable()

The enable() method should enable the component so that it can be selected by the user.

None

disable

ComponentPeer

void disable()

The disable() method should disable the component (gray it out, etc.) so that it cannot be selected by the user.

None

paint

ComponentPeer

void paint(Graphics g)

The paint() method should display the component using the specified Graphics context.

g is a Graphics object used for drawing purposes. For more information on the Graphics class, see the documentation in Chapter 28, "Package java.awt."

repaint

ComponentPeer

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

The repaint() method repaints a part of the component at some specified time in the future.

tm sets the maximum time in milliseconds before the update.

x is the x coordinate of the component's bounding rectangle to repaint.

y is the y coordinate of the component's bounding rectangle to repaint.

width is the width of the component's bounding rectangle to repaint.

height is the height of the component's bounding rectangle to repaint.

print

ComponentPeer

void print(Graphics g)

The print() method should print the component using the specified Graphics object.

g is a Graphics object used for drawing purposes. For more information on the Graphics class, see the documentation in Chapter 28.

reshape

ComponentPeer

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

The reshape() method reshapes the component to the specified bounding rectangle.

x is the x coordinate of the component's new bounding rectangle.

y is the y coordinate of the component's new bounding rectangle.

width is the width of the component's new bounding rectangle.

height is the height of the component's new bounding rectangle.

handleEvent

ComponentPeer

boolean handleEvent(Event e)

The handleEvent() method should handle the specified event for the component.

e is an Event object encapsulating some system event. For more information on the Event class, see the documentation in Chapter 28.

A Boolean value that should be true if the event was handled.

minimumSize

ComponentPeer

Dimension minimumSize()

The minimumSize() method returns the minimum size allowable for the component.

A Dimension object containing the component's minimum size. For more information on the Dimension class, see the documentation in Chapter 28.

preferredSize

ComponentPeer

Dimension preferredSize()

The preferredSize() method returns the preferred size allowable for the component.

A Dimension object containing the component's preferred size. For more information on the Dimension class, see the documentation in Chapter 28.

getColorModel

ComponentPeer

ColorModel getColorModel()

The getColorModel() method returns the ColorModel used for this component.

A ColorModel object that contains the component's ColorModel information. For more information on the ColorModel class, see the documentation in Chapter 29, "Package java.awt.image."

getToolkit

ComponentPeer

Toolkit getToolkit()

The getToolkit() method returns the component's managing Toolkit.

A Toolkit object. For more information on the Toolkit class, see the documentation in Chapter 28.

getGraphics

ComponentPeer

Graphics getGraphics()

The getGraphics() method returns a Graphics context for the component.

A Graphics class used for drawing purposes. For more information on the Graphics class, see the documentation in Chapter 28.

getFontMetrics

ComponentPeer

FontMetrics getFontMetrics(Font font)

The getFontMetrics() method returns the FontMetrics information for the specified Font.

font is a Font object. For more information on the Font class, see the documentation in Chapter 28.

A FontMetrics object containing metrics information on the specified font. For more information on the FontMetrics class, see the documentation in Chapter 28.

dispose

ComponentPeer

void dispose()

The dispose() method disposes of a component's resources and the component itself.

None

setForeground

ComponentPeer

void setForeground(Color c)

The setForeground() method sets the foreground color for the component using the specified color.

c is a Color object specifying which color to use for the foreground color. For more information on the Color class, see the documentation in Chapter 28.

setBackground

ComponentPeer

void setBackground(Color c)

The setBackground() method sets the background color for the component using the specified color.

c is a Color object specifying which color to use for the background color. For more information on the Color class, see the documentation in Chapter 28.

setFont

ComponentPeer

void setFont(Font f)

The setFont() method sets the font to use for this component using the specified font.

f is a Font object specifying which font to use for the component. For more information on the Font class, see the documentation in Chapter 28.

requestFocus

ComponentPeer

void requestFocus()

The requestFocus() method requests the input focus for the component.

None

nextFocus

ComponentPeer

void nextFocus()

The nextFocus() method shifts the focus to the next component on the screen.

None

createImage

ComponentPeer

Image createImage(ImageProducer producer)

The createImage() method creates an Image object using the specified ImageProducer interface.

producer is an ImageProducer interface used to produce an image. For more information on the ImageProducer interface, see the documentation in Chapter 29.

An Image object. For more information on the Image class, see the documentation in Chapter 28.

createImage

ComponentPeer

Image createImage(int width, int height)

This createImage() method creates an image for off-screen use using the specified sizes.

width is the width of the image to be created.

height is the height of the image to be created.

An Image object. For more information on the Image class, see the documentation in Chapter 28.

prepareImage

ComponentPeer

boolean prepareImage(Image img, int w, int h, ImageObserver o)

The prepareImage() method prepares the image for rendering on this component using the specified parameters.

Img is an Image object to be rendered. For more information on the Image class, see the documentation in Chapter 28.

w is the width of the rectangle in which to render the image.

h is the height of the rectangle in which to render the image.

o is the ImageObserver interface used to monitor the Image rendering. For more information on the ImageObserver interface, see the documentation in Chapter 29.

A Boolean value that is true if the image was rendered successfully, false if not.

checkImage

ComponentPeer

int checkImage(Image img, int w, int h, ImageObserver o)

The checkImage() method returns the status of a scaled rendering of a specified Image.

img is an Image object to be rendered. For more information on the Image class, see the documentation in Chapter 28.

w is the width of the rectangle in which to render the image.

h is the height of the rectangle in which to render the image.

o is the ImageObserver interface used to monitor the Image rendering. For more information on the ImageObserver interface, see the documentation in Chapter 29.

An integer value containing the Boolean OR of the ImageObserver status flags. For more information on the ImageObserver class, see the documentation in Chapter 29.

ContainerPeer

ComponentPeer

The ContainerPeer interface extends interface java.awt.peer.ComponentPeer. The ContainerPeer interface provides the basic structure required for container component functionality.

Listing 30.7 shows the declarations for all of the public methods included in the java.awt.peer.ContainerPeer interface.


Listing 30.7. Members of java.awt.peer.ContainerPeer.
public interface ContainerPeer extends ComponentPeer {
  Insets insets()
}

insets

ContainerPeer

Insets insets()

The insets() method returns an Insets object representing the Insets of the container.

An Insets object. For more information on the Insets class, see the documentation in Chapter 28.

DialogPeer

WindowPeer

The DialogPeer interface extends the java.awt.peer.WindowPeer interface. The DialogPeer interface provides the basic structure required for dialog box component functionality.

Listing 30.8 shows the declarations for all of the public methods included in the java.awt.peer.WindowPeer interface.


Listing 30.8. Members of java.awt.peer.DialogPeer.
public interface DialogPeer extends WindowPeer {
  void setTitle(String title)
  void setResizable(boolean resizeable)
}

setTitle

DialogPeer

void setTitle(String title)

The setTitle() method sets the title to be displayed on the dialog's title bar.

title is a String value that will be used as the dialog's title.

setResizable

DialogPeer

void setResizable(boolean resizeable)

The setResizable() method determines the dialog's resize state.

resizeable is a Boolean value that is true if the dialog can be resized, false if not.

FileDialogPeer

DialogPeer

The FileDialogPeer interface extends interface java.awt.peer.DialogPeer. The FileDialogPeer interface provides the basic structure required for file selection dialog component functionality.

Listing 30.9 shows the declarations for all of the public methods included in the java.awt.peer.FileDialogPeer interface.


Listing 30.9. Members of java.awt.peer.FileDialogPeer.
public interface FileDialogPeer extends DialogPeer {
  void setFile(String file)
  void setDirectory(String dir)
  void setFilenameFilter(FilenameFilter filter)
}

setFile

FileDialogPeer

void setFile(String file)

The setFile() method sets the filename to be displayed in the FileDialog.

file is a String value representing a filename.

setDirectory

FileDialogPeer

void setDirectory(String dir)

The setDirectory() method sets the directory to be selected in the FileDialog.

dir is a String value representing the directory name.

setFilenameFilter

FileDialogPeer

void setFilenameFilter(FilenameFilter filter)

The setFilenameFilter() sets the filter to be used in the FileDialog.

filter is a FilenameFilter object used to filter filenames. For more information on the FilenameFilter interface, see the documentation for the java.io package in Chapter 31, "Package java.io."

FramePeer

WindowPeer

The FramePeer interface extends interface java.awt.peer.WindowPeer. The FramePeer interface provides the basic structure required for frame component functionality.

Listing 30.10 shows the declarations for all of the public methods included in the java.awt.peer.FramePeer interface.


Listing 30.10. Members of java.awt.peer.FramePeer.
public interface FramePeer extends WindowPeer {
  void setTitle(String title)
  void setIconImage(Image im)
  void setMenuBar(MenuBar mb)
  void setResizable(boolean resizeable)
  void setCursor(int cursorType)
}

setTitle

FramePeer

void setTitle(String title)

The setTitle() method sets the title of the frame to the specified title string.

title is a String value representing the frame's title.

setIconImage

FramePeer

void setIconImage(Image im)

The setIconImage() method sets the image to be used when the frame is iconized.

im is an Image object. For more information on the Image class, see the documentation in Chapter 28.

setMenuBar

FramePeer

void setMenuBar(MenuBar mb)

The setMenuBar() method sets the menu bar to be used for the frame.

mb is a MenuBar object. For more information on the MenuBar class, see the documentation in Chapter 28.

setResizable

FramePeer

void setResizable(boolean resizeable)

The setResizable() method determines the resize state of the frame.

resizeable is a Boolean value that is true if the frame can be resized, false if not.

setCursor

FramePeer

void setCursor(int cursorType)

The setCursor() method sets the cursor type for the frame.

cursorType is an integer value representing the cursor type. For more information on the Frame class, see the documentation in Chapter 28.

LabelPeer

ComponentPeer

The LabelPeer interface extends interface java.awt.peer.ComponentPeer. The LabelPeer interface provides the basic structure required for label component functionality.

Listing 30.11 shows the declarations for all of the public methods included in the java.awt.peer.LabelPeer interface.


Listing 30.11. Members of java.awt.peer.LabelPeer.
public interface LabelPeer extends ComponentPeer {
  void setText(String label)
  void setAlignment(int alignment)
}

setText

LabelPeer

void setText(String label)

The setText() method sets the text to be displayed on the label.

label is a String value that will be used as the label string.

setAlignment

LabelPeer

void setAlignment(int alignment)

The setAlignment() method sets the alignment type of the label.

alignment is an integer value that determines the alignment of the label (LEFT, RIGHT, or CENTER).

ListPeer

ComponentPeer

The ListPeer interface extends interface java.awt.peer.ComponentPeer. The ListPeer interface provides the basic structure required for list component functionality.

Listing 30.12 shows the declarations for all of the public methods included in the java.awt.peer.ListPeer interface.


Listing 30.12. Members of java.awt.peer.ListPeer.
public interface ListPeer extends ComponentPeer {
  int[] getSelectedIndexes()
  void addItem(String item, int index)
  void delItems(int start, int end)
  void clear()
  void select(int index)
  void deselect(int index)
  void makeVisible(int index)
  void setMultipleSelections(boolean v)
  Dimension preferredSize(int v)
  Dimension minimumSize(int v)
}

getSelectedIndexes

ListPeer

int[] getSelectedIndexes()

The getSelectedIndexes() method returns an array containing the selected indexes in the list.

An integer array containing the indexes that are currently selected in the list.

addItem

ListPeer

void addItem(String item, int index)

The addItem() method adds a String item at the specified index.

item is a String value to be added to the list.

index is an integer value representing the index into the list.

delItems

ListPeer

void delItems(int start, int end)

The delItems() method deletes a range of values from the list using the specified range values.

start is an integer value marking the start of the deletion range.

end is an integer value marking the end of the deletion range.

clear

ListPeer

void clear()

The clear() method clears all elements from the list.

None

select

ListPeer

void select(int index)

This select() method selects the specified index.

index is an integer value specifying the item in the list to be selected.

deselect

ListPeer

void deselect(int index)

The deselect() method deselects an item within the list.

index is an integer value specifying the item in the list to be deselected.

makeVisible

ListPeer

void makeVisible(int index)

The makeVisible() method forces the list to scroll, if necessary, so that the specified index will be made visible to the user.

index is an integer value representing the index to be made visible.

setMultipleSelections

ListPeer

void setMultipleSelections(boolean v)

The setMultipleSelections() method specifies whether the list should allow multiple selections or not.

v is a Boolean value that is true if multiple selections are to be allowed, false if not.

preferredSize

ListPeer

Dimension preferredSize(int v)

The preferredSize() method sets the preferred size for a list of the specified number of items.

vis an integer value specifying the number of items within the list.

A Dimension object containing the preferred size of the list. For more information on the Dimension class, see the documentation in Chapter 28.

minimumSize

ListPeer

Dimension minimumSize(int v)

The minimumSize() method sets the minimum size for a list of the specified number of items.

v is an integer value specifying the number of items within the list.

A Dimension object containing the minimum size of the list. For more information on the Dimension class, see the documentation in Chapter 28.

MenuBarPeer

MenuComponentPeer

The MenuBarPeer interface extends interface java.awt.peer.MenuComponentPeer. The MenuBarPeer interface provides the basic structure required for menu bar component functionality.

Listing 30.13 shows the declarations for all of the public methods included in the java.awt.peer.MenuBarPeer interface.


Listing 30.13. Members of java.awt.peer.MenuBarPeer.
public interface MenuBarPeer extends MenuComponentPeer {
  void addMenu(Menu m)
  void delMenu(int index)
  void addHelpMenu(Menu m)
}

addMenu

MenuBarPeer

void addMenu(Menu m)

The addMenu() method adds the specified Menu to the MenuBar.

m is the Menu object to be added to the MenuBar. For more information on the Menu class, see the documentation in Chapter 28.

delMenu

MenuBarPeer

void delMenu(int index)

The delMenu() method deletes the menu at the specified index from the MenuBar.

index is an integer value representing the index to be deleted from the MenuBar.

addHelpMenu

MenuBarPeer

void addHelpMenu(Menu m)

The addHelpMenu adds a help menu to the MenuBar.

m is the Menu object to be added to the MenuBar. For more information on the Menu class, see the documentation in Chapter 28.

MenuComponentPeer

Object

The MenuComponentPeer interface extends the class java.lang.Object. The MenuComponentPeer interface provides the basic structure required for menu component functionality.

Listing 30.14 shows the declarations for all of the public methods included in the java.awt.peer.MenuComponentPeer interface.


Listing 30.14. Members of java.awt.peer.MenuComponentPeer.
public interface MenuComponentPeer {
  void dispose()
}

dispose

MenuComponentPeer

void dispose()

The dispose() method disposes of a MenuComponent's allocated resources.

MenuItemPeer

MenuComponentPeer

The MenuItemPeer interface extends interface java.awt.peer.MenuComponentPeer. The MenuItemPeer interface provides the basic structure required for menu item component functionality.

Listing 30.15 shows the declarations for all of the public methods included in the java.awt.peer.MenuItemPeer interface.


Listing 30.15. Members of java.awt.peer.MenuItemPeer.
public interface MenuItemPeer extends MenuComponentPeer {
  void setLabel(String label)
  void enable()
  void disable()
}

setLabel

MenuItemPeer

void setLabel(String label)

The setLabel() method sets the label string that will be displayed on the MenuItem.

label is a String value that will be displayed as the MenuItem's label.

enable

MenuItemPeer

void enable()

The enable() method enables the MenuItem for user selection.

disable

MenuItemPeer

void disable()

The disable() method disables the MenuItem for user selection.

MenuPeer

MenuItemPeer

The MenuPeer interface extends interface java.awt.peer.MenuItemPeer. The MenuPeer interface provides the basic structure required for menu component functionality.

Listing 30.16 shows the declarations for all of the public methods included in the java.awt.peer.MenuPeer interface.


Listing 30.16. Members of java.awt.peer.MenuPeer.
public interface MenuPeer extends MenuItemPeer {
  void addSeparator()
  void addItem(MenuItem item)
  void delItem(int index)
}

addSeparator

MenuPeer

void addSeparator()

The addSeparator() method adds a separator element to the Menu. A separator is an item, such as a line, which cannot be selected by the user and will not trigger a menu selection event.

addItem

MenuPeer

void addItem(MenuItem item)

The addItem() method adds a MenuItem to the Menu.

item is a MenuItem object. For more information on the MenuItem class, see the documentation in Chapter 28.

delItem

MenuPeer

void delItem(int index)

The delItem() method deletes the menu item at the specified index.

index is an integer value representing the index on the menu to be deleted.

PanelPeer

ContainerPeer

The PanelPeer interface extends interface java.awt.peer.ContainerPeer. The PanelPeer interface provides the basic structure required for panel component functionality.

Listing 30.17 shows the declarations for all of the public methods included in the java.awt.peer.PanelPeer interface.


Listing 30.17. Members of java.awt.peer.PanelPeer.
public interface PanelPeer extends ContainerPeer {
}

ScrollbarPeer

ComponentPeer

The ScrollbarPeer interface extends interface java.awt.peer.ComponentPeer. The ScrollbarPeer interface provides the basic structure required for scrollbar component functionality.

Listing 30.18 shows the declarations for all of the public methods included in the java.awt.peer.ScrollbarPeer interface.


Listing 30.18. Members of java.awt.peer.ScrollbarPeer.
public interface ScrollbarPeer extends ComponentPeer {
  void setValue(int value)
  void setValues(int value, int visible, int minimum, int maximum)
  void setLineIncrement(int l)
  void setPageIncrement(int l)
}

setValue

ScrollbarPeer

void setValue(int value)

The setValue() method sets the value of the Scrollbar.

value is an integer value representing the value (position) of the Scrollbar.

setValues

ScrollbarPeer

void setValues(int value, int visible, int minimum, int maximum)

The setValues() method sets the specified properties of the scrollbar.

value is the new value of the scrollbar.

visible is the number of units to be displayed by the scrollbar.

minimum is the minimum value of the scrollbar.

maximum is the maximum value of the scrollbar.

setLineIncrement

ScrollbarPeer

void setLineIncrement(int l)

The setLineIncrement() method sets the increment value represented by a user clicking on a scrollbar line up/down widget.

l is an integer value representing the line increment value.

setPageIncrement

ScrollbarPeer

void setPageIncrement(int l)

The setPageIncrement() method sets the increment value represented by a user clicking on a scrollbar page up/down widget.

l is an integer value representing the page increment value.

TextAreaPeer

TextComponentPeer

The TextAreaPeer interface extends interface java.awt.peer.TextComponentPeer. The TextAreaPeer interface provides the basic structure required for text area component functionality.

Listing 30.19 shows the declarations for all of the public methods included in the java.awt.peer.TextAreaPeer interface.


Listing 30.19. Members of java.awt.peer.TextAreaPeer.
public interface TextAreaPeer extends TextComponentPeer {
  void insertText(String txt, int pos)
  void replaceText(String txt, int start, int end)
  Dimension preferredSize(int rows, int cols)
  Dimension minimumSize(int rows, int cols)
}

insertText

TextAreaPeer

void insertText(String txt, int pos)

The insertText() method inserts the specified text at the specified position within the TextArea.

txt is a String value representing the text to be inserted.

pos is an integer value representing the position within the TextArea at which to insert the text.

replaceText

TextAreaPeer

void replaceText(String txt, int start, int end)

The replaceText() method replaces text at the specified positions with the new text.

txt is a String value representing the text to be inserted into the TextArea.

start is an integer value containing the start position of the text to be replaced.

end is an integer value containing the end position of the text to be replaced.

preferredSize

TextAreaPeer

Dimension preferredSize(int rows, int cols)

The preferredSize() method returns the preferred size of a TextArea of the specified dimensions.

rows is the number of rows in the TextArea.

cols is the number of columns in the TextArea.

A Dimension object containing the preferred size of the TextArea. For more information on the Dimension class, see the documentation earlier in the chapter.

minimumSize

TextAreaPeer

Dimension minimumSize(int rows, int cols)

The minimumSize() method returns the minimum size of a TextArea of the specified dimensions.

rows is the number of rows in the TextArea.

cols is the number of columns in the TextArea.

A Dimension object containing the minimum size of the TextArea. For more information on the Dimension class, see the documentation in Chapter 28.

TextComponentPeer

ComponentPeer

The TextComponentPeer interface extends interface java.awt.peer.ComponentPeer. The TextComponentPeer interface provides the basic structure required for text component functionality.

Listing 30.20 shows the declarations for all of the public methods included in the java.awt.peer.TextComponentPeer interface.


Listing 30.20. Members of java.awt.peer.TextComponentPeer.
public interface TextComponentPeer extends ComponentPeer {
  void setEditable(boolean editable)
  String getText()
  void setText(String l)
  int getSelectionStart()
  int getSelectionEnd()
  void select(int selStart, int selEnd)
}

setEditable

TextComponentPeer

void setEditable(boolean editable)

The setEditable() method is used to the set the TextComponent's editable state.

A Boolean value that is true if the text can be edited, false if not.

getText

TextComponentPeer

String getText()

The getText() method returns the TextComponent's displayed text.

A String value representing the text contained in the TextComponent.

setText

TextComponentPeer

void setText(String l)

The setText() method sets the text to be displayed in the TextComponent.

l is a String value to be displayed by the TextComponent.

getSelectionStart

TextComponentPeer

int getSelectionStart()

The getSelectionStart() method returns the position of the first selected character in the TextComponent.

An integer value specifying the position of the first selected character in the TextComponent.

getSelectionEnd

TextComponentPeer

int getSelectionEnd()

The getSelectionEnd() method returns the position of the last selected character in the TextComponent.

An integer value specifying the position of the last selected character in the TextComponent.

select

TextComponentPeer

void select(int selStart, int selEnd)

The select() method selects the specified text within the TextComponent.

selStart is an integer value representing the starting character to be selected.

selEnd is an integer value representing the ending character to be selected.

TextFieldPeer

TextComponentPeer

The TextFieldPeer interface extends interface java.awt.peer.TextComponentPeer. The TextFieldPeer interface provides the basic structure required for text field component functionality.

Listing 30.21 shows the declarations for all of the public methods included in the java.awt.peer.TextFieldPeer interface.


Listing 30.21. Members of java.awt.peer.TextFieldPeer.
public interface TextFieldPeer extends TextComponentPeer {
  void setEchoCharacter(char c)
  Dimension preferredSize(int cols)
  Dimension minimumSize(int cols)
}

setEchoCharacter

TextFieldPeer

void setEchoCharacter(char c)

The setEchoCharacter() method sets the Echo character to be echoed to the screen as the user types.

c is a character value to be displayed no matter what character the user types.

preferredSize

TextFieldPeer

Dimension preferredSize(int cols)

The preferredSize() method returns the preferred size of the TextField based on the specified number of characters.

cols is an integer value containing the number of characters in the text field.

A Dimension object containing the preferred size of the TextField. For more information on the Dimension class, see the documentation in Chapter 28.

minimumSize

TextFieldPeer

Dimension minimumSize(int cols)

The minimumSize() method returns the minimum size of the TextField based on the specified number of characters.

cols is an integer value containing the number of characters in the text field.

A Dimension object containing the minimum size of the TextField. For more information on the Dimension class, see the documentation in Chapter 28.

WindowPeer

ContainerPeer

The WindowPeer interface extends interface java.awt.peer.ContainerPeer. The WindowPeer interface provides the basic structure required for window component functionality.

Listing 30.22 shows the declarations for all of the public methods included in the java.awt.peer.ContainerPeer interface.


Listing 30.22. Members of java.awt.peer.WindowPeer.
public interface WindowPeer extends ContainerPeer {
  void toFront()
  void toBack()
}

toFront

WindowPeer

void toFront()

The toFront() method moves the Window to the front of the display.

toBack

WindowPeer

void toBack()

The toBack() method moves the Window to the back of the display.