SlideShare una empresa de Scribd logo
1 de 23
JAVA
AWT
Prepared by
Miss. Arati A. Gadgil
•Java AWT (Abstract Windowing Toolkit) is an API to develop
GUI or window-based application in java.
•Java AWT components are platform-dependent i.e. components
are displayed according to the view of operating system. AWT is
heavyweight i.e. its components uses the resources of system.
•The java.awt package provides classes for AWT api such as
TextField, Label, TextArea, RadioButton, CheckBox, Choice,
List etc.
AWT
2
Java AWT
Hierarchy
3
Container
The Container is a component in AWT that can contain another
components like buttons, textfields, labels etc. The classes that extends
Container class are known as container such as Frame, Dialog and Panel.
Window
The window is the container that have no borders and menu bars. You
must use frame, dialog or another window for creating a window
Panel
The Panel is the container that doesn't contain title bar and menu bars. It
can have other components like button, textfield etc.
Frame
The Frame is the container that contain title bar and can have menu bars.
It can have other components like button, textfield etc.
4
5
Useful Methods of Component class
public void add(Component c)
inserts a component on this component
public void setSize(int width,int height)
sets the size (width and height) of the component.
public void setLayout(LayoutManager m)
defines the layout manager for the component.
public void setVisible(boolean status)
changes the visibility of the component, by default false.
import java.awt.*;
class frm1 extends Frame
{
frm1(String s)
{
super(s);
setSize(400,400);
setVisible(true);
}
public static void main(String []ar)
{
frm1 a=new frm1("first
window");
}
}
First frame
Output
6
import java.awt.*;
class First extends Frame
{
First()
{
Button b=new Button("click me");
b.setBounds(30,100,80,30) ;// setting button position
add(b);//adding button into frame
setSize(300,300);//frame size 300 width and 300 height
setLayout(null);//no layout manager
setVisible(true);//now frame will be visible, by default not
visible
}
public static void main(String args[])
{
First f=new First();
}
} 7
Output
The setBounds(int xaxis, int yaxis, int width,
int height)
Method is used in the above example that sets
the position of the awt button.
b.setBounds(30,100,80,30)
8
Changing the state of an object is known as an
event. For example, click on button, dragging
mouse etc. The java.awt.event package provides
many event classes and Listener interfaces for
event handling.
Event Classes Listener Interfaces
ActionEvent ActionListener
MouseEvent MouseListener and
MouseMotionListener
MouseWheelEvent MouseWheelListener
KeyEvent KeyListener
ItemEvent ItemListener
TextEvent TextListener
AdjustmentEvent AdjustmentListener
WindowEvent WindowListener
ComponentEvent ComponentListener
ContainerEvent ContainerListener
FocusEvent FocusListener
Event and Listener (Java Event Handling)
9
import java.awt.*; import java.awt.event.*;
class eventi extends Frame implements
ActionListener
{ TextField tf;
eventi()
{
tf=new TextField();
tf.setBounds(60,50,170,20);
Button b=new Button("click me");
b.setBounds(100,120,80,30);
b.addActionListener(this);
add(b);add(tf);
setSize(300,300);
setLayout(null);
setVisible(true);
}
public void actionPerformed(ActionEvent
e)
{ tf.setText("Welcome");
}
public static void main(String args[])
{ new eventi();
}
10
AWT UI Elements
Label
constructors
Label() Constructs an empty label.
Label(String text) Constructs a new label with the specified
string of text, left justified.
Label(String text, int alignment)
Constructs a new label that presents the specified string of
text with the specified alignment.
static int CENTER -- Indicates that the label should be centered.
static int LEFT -- Indicates that the label should be left justified.
static int RIGHT -- Indicates that the label should be right justified
11
Methods
int getAlignment()
Gets the current alignment of this label.
String getText()
Gets the text of this label.
void setAlignment(int alignment)
Sets the alignment for this label to the specified alignment.
void setText(String text)
Sets the text for this label to the specified text
12
Button
Constructors
Button()
Constructs a button with an empty string for its
label.
Button(String text)
Constructs a new button with specified label.
13
Methods
void addActionListener(ActionListener l) Adds the specified action
listener to receive action events from this button.
String getActionCommand()
Returns the command name of the action event fired by this button.
String getLabel()
Gets the label of this button
void removeActionListener(ActionListener l)Removes the specified
action listener so that it no longer receives action events from this button
void setActionCommand(String command)
Sets the command name for the action event fired by this button.
void setLabel(String label)
Sets the button's label to be the specified string 14
CheckBox
Constructors
Checkbox()
Creates a check box with an empty string for its label.
Checkbox(String label, boolean state) Creates a check box with
the specified label and sets the specified state.
Checkbox(String label, boolean state, CheckboxGroup group)
Constructs a Checkbox with the specified label, set to the specified
state, and in the specified check box group.
Checkbox(String label, CheckboxGroup group, boolean state)
Creates a check box with the specified label, in the specified check
box group, and set to the specified state.
15
void addItemListener(ItemListener l)
Adds the specified item listener to receive item events from this
check box.
CheckboxGroup getCheckboxGroup()
Determines this check box's group.
String getLabel()
Gets the label of this check box
boolean getState()
Determines whether this check box is in the on or off state.
void setCheckboxGroup(CheckboxGroup g)
Sets this check box's group to the specified check box group.
void setState(boolean state)
Sets the state of this check box to the specified state. 16
List
The List represents a list of text items. The list can be configured to that
user can choose either one item or multiple items.
Constructors
List()
Creates a new scrolling list.
List(int rows) Creates a new scrolling list initialized with the specified
number of visible lines
List(int rows, boolean multipleMode)
Creates a new scrolling list initialized to display the specified
number of rows.
17
void add(String item)
Adds the specified item to the end of scrolling list.
void add(String item, int index) Adds the specified item to the the
scrolling list at the position indicated by the index.
void addActionListener(ActionListener l) Adds the specified
action listener to receive action events from this list
void clear()
Deprecated. As of JDK version 1.1, replaced by removeAll().
void delItem(int position)
Deprecated. replaced by remove(String) and remove(int).
void deselect(int index)
Deselects the item at the specified index.
18
String getItem(int index)
Gets the item associated with the specified index.
int getItemCount()
Gets the number of items in the list
String[] getItems()
Gets the items in the list.
int getRows()
Gets the number of visible lines in this list
int getSelectedIndex()
Gets the index of the selected item on the list
19
boolean isMultipleMode()
Determines whether this list allows multiple selections.
void remove(int position)
Removes the item at the specified position from this scrolling
list.
void remove(String item)
Removes the first occurrence of an item from the list
20
TextField
Constructor
TextField()
Constructs a new text field.
TextField(int columns)
Constructs a new empty text field with the specified number of
columns.
TextField(String text)
Constructs a new text field initialized with the specified text.
TextField(String text, int columns)
Constructs a new text field initialized with the specified text to be
displayed, and wide enough to hold the specified number of
columns. 21
void addActionListener(ActionListener l)
Adds the specified action listener to receive action
events from this text field.
int getColumns()
Gets the number of columns in this text field
void setColumns(int columns)
Sets the number of columns in this text field
void setText(String t)
Sets the text that is presented by this text component
to be the specified text.
22
Thank You
23

Más contenido relacionado

La actualidad más candente

Java exception handling
Java exception handlingJava exception handling
Java exception handling
BHUVIJAYAVELU
 

La actualidad más candente (20)

Java Exception handling
Java Exception handlingJava Exception handling
Java Exception handling
 
Event handling
Event handlingEvent handling
Event handling
 
Java exception handling
Java exception handlingJava exception handling
Java exception handling
 
Swing
SwingSwing
Swing
 
Event handling
Event handlingEvent handling
Event handling
 
Event Handling in java
Event Handling in javaEvent Handling in java
Event Handling in java
 
Arrays in Java
Arrays in JavaArrays in Java
Arrays in Java
 
Applets in java
Applets in javaApplets in java
Applets in java
 
Python set
Python setPython set
Python set
 
Vectors in Java
Vectors in JavaVectors in Java
Vectors in Java
 
Java Collections
Java  Collections Java  Collections
Java Collections
 
Python GUI Programming
Python GUI ProgrammingPython GUI Programming
Python GUI Programming
 
Java input
Java inputJava input
Java input
 
Applets
AppletsApplets
Applets
 
Method overloading
Method overloadingMethod overloading
Method overloading
 
Java interfaces
Java interfacesJava interfaces
Java interfaces
 
Java Networking
Java NetworkingJava Networking
Java Networking
 
Fragment
Fragment Fragment
Fragment
 
Java package
Java packageJava package
Java package
 
Wrapper classes
Wrapper classes Wrapper classes
Wrapper classes
 

Similar a Java awt

PPThbkjn;l sdc a;s'jjN djkHBSDjhhIDoj LKD
PPThbkjn;l sdc a;s'jjN djkHBSDjhhIDoj LKDPPThbkjn;l sdc a;s'jjN djkHBSDjhhIDoj LKD
PPThbkjn;l sdc a;s'jjN djkHBSDjhhIDoj LKD
chessvashisth
 

Similar a Java awt (20)

AWT New-3.pptx
AWT New-3.pptxAWT New-3.pptx
AWT New-3.pptx
 
CORE JAVA-2
CORE JAVA-2CORE JAVA-2
CORE JAVA-2
 
Unit-1 awt advanced java programming
Unit-1 awt advanced java programmingUnit-1 awt advanced java programming
Unit-1 awt advanced java programming
 
engineeringdsgtnotesofunitfivesnists.ppt
engineeringdsgtnotesofunitfivesnists.pptengineeringdsgtnotesofunitfivesnists.ppt
engineeringdsgtnotesofunitfivesnists.ppt
 
java-Unit4 chap2- awt controls and layout managers of applet
java-Unit4 chap2- awt controls and layout managers of appletjava-Unit4 chap2- awt controls and layout managers of applet
java-Unit4 chap2- awt controls and layout managers of applet
 
java- Abstract Window toolkit
java- Abstract Window toolkitjava- Abstract Window toolkit
java- Abstract Window toolkit
 
object oriented programming examples
object oriented programming examplesobject oriented programming examples
object oriented programming examples
 
Swing
SwingSwing
Swing
 
Java swing
Java swingJava swing
Java swing
 
DSJ_Unit III.pdf
DSJ_Unit III.pdfDSJ_Unit III.pdf
DSJ_Unit III.pdf
 
Advanced java programming
Advanced java programmingAdvanced java programming
Advanced java programming
 
Basic of Abstract Window Toolkit(AWT) in Java
Basic of Abstract Window Toolkit(AWT) in JavaBasic of Abstract Window Toolkit(AWT) in Java
Basic of Abstract Window Toolkit(AWT) in Java
 
Jp notes
Jp notesJp notes
Jp notes
 
Java swing
Java swingJava swing
Java swing
 
Awt, Swing, Layout managers
Awt, Swing, Layout managersAwt, Swing, Layout managers
Awt, Swing, Layout managers
 
PPThbkjn;l sdc a;s'jjN djkHBSDjhhIDoj LKD
PPThbkjn;l sdc a;s'jjN djkHBSDjhhIDoj LKDPPThbkjn;l sdc a;s'jjN djkHBSDjhhIDoj LKD
PPThbkjn;l sdc a;s'jjN djkHBSDjhhIDoj LKD
 
Java Abstract Window Toolkit (AWT) Presentation. 2024
Java Abstract Window Toolkit (AWT) Presentation. 2024Java Abstract Window Toolkit (AWT) Presentation. 2024
Java Abstract Window Toolkit (AWT) Presentation. 2024
 
Java Abstract Window Toolkit (AWT) Presentation. 2024
Java Abstract Window Toolkit (AWT) Presentation. 2024Java Abstract Window Toolkit (AWT) Presentation. 2024
Java Abstract Window Toolkit (AWT) Presentation. 2024
 
Lecture8 oopj
Lecture8 oopjLecture8 oopj
Lecture8 oopj
 
Unit 5 java-awt (1)
Unit 5 java-awt (1)Unit 5 java-awt (1)
Unit 5 java-awt (1)
 

Más de Arati Gadgil

Más de Arati Gadgil (16)

Java adapter
Java adapterJava adapter
Java adapter
 
Java swing
Java swingJava swing
Java swing
 
Java applet
Java appletJava applet
Java applet
 
Java layoutmanager
Java layoutmanagerJava layoutmanager
Java layoutmanager
 
Java stream
Java streamJava stream
Java stream
 
Java thread
Java threadJava thread
Java thread
 
Java networking
Java networkingJava networking
Java networking
 
Java jdbc
Java jdbcJava jdbc
Java jdbc
 
Java package
Java packageJava package
Java package
 
Java interface
Java interfaceJava interface
Java interface
 
Java inheritance
Java inheritanceJava inheritance
Java inheritance
 
Java eventhandling
Java eventhandlingJava eventhandling
Java eventhandling
 
Java exception
Java exception Java exception
Java exception
 
Java collection
Java collectionJava collection
Java collection
 
Java class
Java classJava class
Java class
 
Java basic
Java basicJava basic
Java basic
 

Último

Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
ciinovamais
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
heathfieldcps1
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
ZurliaSoop
 

Último (20)

Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docx
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docx
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
Third Battle of Panipat detailed notes.pptx
Third Battle of Panipat detailed notes.pptxThird Battle of Panipat detailed notes.pptx
Third Battle of Panipat detailed notes.pptx
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
 

Java awt

  • 2. •Java AWT (Abstract Windowing Toolkit) is an API to develop GUI or window-based application in java. •Java AWT components are platform-dependent i.e. components are displayed according to the view of operating system. AWT is heavyweight i.e. its components uses the resources of system. •The java.awt package provides classes for AWT api such as TextField, Label, TextArea, RadioButton, CheckBox, Choice, List etc. AWT 2
  • 4. Container The Container is a component in AWT that can contain another components like buttons, textfields, labels etc. The classes that extends Container class are known as container such as Frame, Dialog and Panel. Window The window is the container that have no borders and menu bars. You must use frame, dialog or another window for creating a window Panel The Panel is the container that doesn't contain title bar and menu bars. It can have other components like button, textfield etc. Frame The Frame is the container that contain title bar and can have menu bars. It can have other components like button, textfield etc. 4
  • 5. 5 Useful Methods of Component class public void add(Component c) inserts a component on this component public void setSize(int width,int height) sets the size (width and height) of the component. public void setLayout(LayoutManager m) defines the layout manager for the component. public void setVisible(boolean status) changes the visibility of the component, by default false.
  • 6. import java.awt.*; class frm1 extends Frame { frm1(String s) { super(s); setSize(400,400); setVisible(true); } public static void main(String []ar) { frm1 a=new frm1("first window"); } } First frame Output 6
  • 7. import java.awt.*; class First extends Frame { First() { Button b=new Button("click me"); b.setBounds(30,100,80,30) ;// setting button position add(b);//adding button into frame setSize(300,300);//frame size 300 width and 300 height setLayout(null);//no layout manager setVisible(true);//now frame will be visible, by default not visible } public static void main(String args[]) { First f=new First(); } } 7
  • 8. Output The setBounds(int xaxis, int yaxis, int width, int height) Method is used in the above example that sets the position of the awt button. b.setBounds(30,100,80,30) 8
  • 9. Changing the state of an object is known as an event. For example, click on button, dragging mouse etc. The java.awt.event package provides many event classes and Listener interfaces for event handling. Event Classes Listener Interfaces ActionEvent ActionListener MouseEvent MouseListener and MouseMotionListener MouseWheelEvent MouseWheelListener KeyEvent KeyListener ItemEvent ItemListener TextEvent TextListener AdjustmentEvent AdjustmentListener WindowEvent WindowListener ComponentEvent ComponentListener ContainerEvent ContainerListener FocusEvent FocusListener Event and Listener (Java Event Handling) 9
  • 10. import java.awt.*; import java.awt.event.*; class eventi extends Frame implements ActionListener { TextField tf; eventi() { tf=new TextField(); tf.setBounds(60,50,170,20); Button b=new Button("click me"); b.setBounds(100,120,80,30); b.addActionListener(this); add(b);add(tf); setSize(300,300); setLayout(null); setVisible(true); } public void actionPerformed(ActionEvent e) { tf.setText("Welcome"); } public static void main(String args[]) { new eventi(); } 10
  • 11. AWT UI Elements Label constructors Label() Constructs an empty label. Label(String text) Constructs a new label with the specified string of text, left justified. Label(String text, int alignment) Constructs a new label that presents the specified string of text with the specified alignment. static int CENTER -- Indicates that the label should be centered. static int LEFT -- Indicates that the label should be left justified. static int RIGHT -- Indicates that the label should be right justified 11
  • 12. Methods int getAlignment() Gets the current alignment of this label. String getText() Gets the text of this label. void setAlignment(int alignment) Sets the alignment for this label to the specified alignment. void setText(String text) Sets the text for this label to the specified text 12
  • 13. Button Constructors Button() Constructs a button with an empty string for its label. Button(String text) Constructs a new button with specified label. 13
  • 14. Methods void addActionListener(ActionListener l) Adds the specified action listener to receive action events from this button. String getActionCommand() Returns the command name of the action event fired by this button. String getLabel() Gets the label of this button void removeActionListener(ActionListener l)Removes the specified action listener so that it no longer receives action events from this button void setActionCommand(String command) Sets the command name for the action event fired by this button. void setLabel(String label) Sets the button's label to be the specified string 14
  • 15. CheckBox Constructors Checkbox() Creates a check box with an empty string for its label. Checkbox(String label, boolean state) Creates a check box with the specified label and sets the specified state. Checkbox(String label, boolean state, CheckboxGroup group) Constructs a Checkbox with the specified label, set to the specified state, and in the specified check box group. Checkbox(String label, CheckboxGroup group, boolean state) Creates a check box with the specified label, in the specified check box group, and set to the specified state. 15
  • 16. void addItemListener(ItemListener l) Adds the specified item listener to receive item events from this check box. CheckboxGroup getCheckboxGroup() Determines this check box's group. String getLabel() Gets the label of this check box boolean getState() Determines whether this check box is in the on or off state. void setCheckboxGroup(CheckboxGroup g) Sets this check box's group to the specified check box group. void setState(boolean state) Sets the state of this check box to the specified state. 16
  • 17. List The List represents a list of text items. The list can be configured to that user can choose either one item or multiple items. Constructors List() Creates a new scrolling list. List(int rows) Creates a new scrolling list initialized with the specified number of visible lines List(int rows, boolean multipleMode) Creates a new scrolling list initialized to display the specified number of rows. 17
  • 18. void add(String item) Adds the specified item to the end of scrolling list. void add(String item, int index) Adds the specified item to the the scrolling list at the position indicated by the index. void addActionListener(ActionListener l) Adds the specified action listener to receive action events from this list void clear() Deprecated. As of JDK version 1.1, replaced by removeAll(). void delItem(int position) Deprecated. replaced by remove(String) and remove(int). void deselect(int index) Deselects the item at the specified index. 18
  • 19. String getItem(int index) Gets the item associated with the specified index. int getItemCount() Gets the number of items in the list String[] getItems() Gets the items in the list. int getRows() Gets the number of visible lines in this list int getSelectedIndex() Gets the index of the selected item on the list 19
  • 20. boolean isMultipleMode() Determines whether this list allows multiple selections. void remove(int position) Removes the item at the specified position from this scrolling list. void remove(String item) Removes the first occurrence of an item from the list 20
  • 21. TextField Constructor TextField() Constructs a new text field. TextField(int columns) Constructs a new empty text field with the specified number of columns. TextField(String text) Constructs a new text field initialized with the specified text. TextField(String text, int columns) Constructs a new text field initialized with the specified text to be displayed, and wide enough to hold the specified number of columns. 21
  • 22. void addActionListener(ActionListener l) Adds the specified action listener to receive action events from this text field. int getColumns() Gets the number of columns in this text field void setColumns(int columns) Sets the number of columns in this text field void setText(String t) Sets the text that is presented by this text component to be the specified text. 22