Using AWT Controls, Layout Managers, and Menus - PowerPoint PPT Presentation

1 / 15
About This Presentation
Title:

Using AWT Controls, Layout Managers, and Menus

Description:

All awt controls need to be added to the component. add(variableName) ... how, int horz, int vert) Constants ... numRows, int numColumns, int horz, int vert) ... – PowerPoint PPT presentation

Number of Views:700
Avg rating:3.0/5.0
Slides: 16
Provided by: jpe897
Category:

less

Transcript and Presenter's Notes

Title: Using AWT Controls, Layout Managers, and Menus


1
Using AWT Controls, Layout Managers, and Menus
  • Chapter 22

2
AWT Controls
  • Labels
  • Buttons
  • Check boxes
  • Choice Lists
  • Lists
  • Scroll bars
  • Text Fields
  • Text Boxes
  • All awt controls need to be added to the
    component
  • add(variableName)

3
Labels
  • Contructors
  • Label( )
  • Label (String str)
  • Label (String str, int how)
  • Methods
  • void setText(String str)
  • String getText( )
  • Constants
  • Label.LEFT, Label.RIGHT, Label.CENTER

4
Buttons
  • Contructors
  • Button( )
  • Button (String str)
  • Methods
  • void setLabel(String str)
  • String getLabel( )

5
Check Boxes
  • Contructors
  • Checkbox( )
  • Checkbox(String str)
  • Checkbox(String str, boolean on)
  • Checkbox(String str, boolean on, CheckBoxGroup
    cbGroup)
  • Checkbox(String, CheckboxGroup cbGroup, boolean
    on)
  • Methods
  • void setState(boolean on)
  • String getLabel(String str)
  • boolean getState( )
  • String getLabel( )
  • Constructor
  • CheckboxGroup( )

6
Choice Controls(Drop-down Menus)
  • Contructors
  • Choice( )
  • Methods
  • void addItem(String str)
  • void add(String str)
  • String getSelectedItem( )
  • int getSelectedIndex( )
  • int getItemCount( )
  • void select(int index)
  • void select(String name)

7
Choice Controls(Drop-down Menus)
  • Contructors
  • Choice( )
  • Methods
  • void addItem(String str)
  • void add(String str)
  • String getSelectedItem( )
  • int getSelectedIndex( )
  • int getItemCount( )
  • void select(int index)
  • void select(String name)

8
Lists
  • Contructors
  • List ( )
  • List (int numRows)
  • List (int numRows, boolean multipleSelect)
  • Methods
  • void add(String str)
  • void add(String str, int index)
  • String getSelectedItem( ) / String
    getSelectedItems( )
  • int getSelectedIndex( ) / int
    getSelectedIndexes( )
  • int getItemCount( )
  • void select(int index)

9
TextFields
  • Contructors
  • TextField ( )
  • TextField (int numChars)
  • TextField(String str)
  • TextField(String str, int numChars)
  • Methods
  • void setText(String str)
  • String getText( )
  • String getSelectedText( )
  • void select (int startIndex, int endIndex)
  • void setEchoChar(char ch)

10
TextArea
  • Contructors
  • TextArea ( )
  • TextArea (int numLines, int numChars)
  • TextArea(String str)
  • TextArea(String str, int numLines, int numChars,
    int sBars)
  • Methods
  • void setText(String str)
  • String getText( )
  • String getSelectedText( )

11
Panels
  • Container for components
  • A window
  • Without title bar, menu bar, or border
  • add(variableNameOfComponent)
  • place panels on Layout Managers

12
Layout Managers
  • FlowLayout
  • BorderLayout
  • GridLayout
  • CardLayout

13
FlowLayout
  • FlowLayout
  • Similar to word processor
  • Components added left to right
  • Constructors
  • FlowLayout( ) // default centered
  • FlowLayout(int how)
  • FlowLayout (int how, int horz, int vert)
  • Constants
  • FlowLayout.LEFT, FlowLayout.CENTER,
    FlowLayout.RIGHT

14
BorderLayout
  • BorderLayout
  • Five Major Areas
  • Top, Left, Center, Right, Bottom
  • Constructors
  • BorderLayout( )
  • BorderLayout(int horz, int vert)
  • Constants
  • BorderLayout.CENTER, BorderLayout.EAST,
    BorderLayout.NORTH, BorderLayout.South,
    BorderLayout.WEST

15
GridLayout
  • GridLayout
  • Table
  • Constructors
  • GridLayout( )
  • GridLayout(int numRows, int numColumns)
  • GridLayout(int numRows, int numColumns, int horz,
    int vert)
Write a Comment
User Comments (0)
About PowerShow.com