Applet - PowerPoint PPT Presentation

About This Presentation
Title:

Applet

Description:

Applet – PowerPoint PPT presentation

Number of Views:15
Avg rating:3.0/5.0
Slides: 13
Provided by: effien
Learn more at: https://owd.tcnj.edu
Category:
Tags: applet | reimport

less

Transcript and Presenter's Notes

Title: Applet


1
Applet
  • contains GUI components such as
  • buttons
  • text fields
  • labels
  • check boxes
  • choices

2
GUI Components
  • when GUI components are clicked, dragged, or
    manipulated, events are triggered

3
Panel
a container for related GUI components
  • a grouping mechanism

4
Button
component that triggers a specific action
button
5
Button
import java.awt. import java.applet. public
class SampleButton extends Applet public
void init() Panel pnlName new
Panel() //change color of
panel pnlName.setBackground(Color.
green) //command button
Button cmdDeposit new
Button("Deposit") //add command
button to panel
pnlName.add(cmdDeposit)
//command button Button
cmdWithdraw new Button("Withdraw")
continuation
pnlName.add(cmdWithdraw) add(pnlName)

6
TextField
  • A component that allows input into the program or
    to display information

textfield
7
TextField
import java.awt. import java.applet. public
class SampleTextField extends Applet
public void init() Panel pnlName new
Panel() //change color of panel pnlName.setBackg
round(Color.green) TextField txtName new
TextField (20) pnlName.add(txtName) Panel
pnlButtons new Panel() pnlButtons.setBackground
(Color.black) //command button Button
cmdDeposit new Button("Deposit") //add command
button to panel pnlButtons.add(cmdDeposit)
Button cmdWithdraw new Button("Withdraw") //ad
d command button to panel pnlButtons.add(cmdWithdr
aw) add(pnlName) add(pnlButtons)
8
Label
  • a component that provides information
  • it is read only

label
9
Label
import java.awt. import java.applet. public
class SampleLabel extends Applet public void
init() Panel pnlLogin new Panel() //change
color of panel pnlLogin.setBackground(Color.green)
Label lblLogin new Label("Login
") pnlLogin.add(lblLogin) TextField txtLogin
new TextField (10) pnlLogin.add(txtLogin) Panel
pnlPassWord new Panel() pnlPassWord.setBackgro
und(Color.red) Label lblPassWord new
Label("Pass word ") pnlPassWord.add(lblPassWord)

TextField txtPassWord new TextField(10) pnlPass
Word.add(txtPassWord) Panel pnlButtons new
Panel() pnlButtons.setBackground(Color.black) B
utton cmdSubmit new Button("Submit") pnlButtons
.add(cmdSubmit) add(pnlLogin)
add(pnlPassWord) add(pnlButtons)
10
Check Box
Check box
  • offers a set of choices
  • any number of check boxes can be selected

check box
11
Options
Check box
  • offers a set of exclusive choices
  • only one option can be selected

option
12
Check Boxes / Options
import java.awt. import java.applet. public
class CheckOptions extends Applet public void
init() Panel pnlCheck new Panel() //change
color of panel pnlCheck.setBackground(Color.green)
Checkbox chkApples new Checkbox
("Apples") pnlCheck.add(chkApples) Checkbox
chkOranges new Checkbox ("Oranges") pnlCheck.ad
d(chkOranges) Checkbox chkPears new Checkbox
("pears") pnlCheck.add(chkPears)
Panel pnlOption new Panel() pnlOption.setBackgr
ound(Color.red) Choice optGender new
Choice() optGender.add("Female") optGender.add("
Male") pnlOption.add(optGender) add(pnlCheck
) add(pnlOption)
option
check box
Write a Comment
User Comments (0)
About PowerShow.com