Presentation is loading. Please wait.

Presentation is loading. Please wait.

Applets, Graphical User Interfaces, and Thread / Chapter 9 1 Applet contains GUI components such as –buttons –text fields –labels –check boxes –choices.

Similar presentations


Presentation on theme: "Applets, Graphical User Interfaces, and Thread / Chapter 9 1 Applet contains GUI components such as –buttons –text fields –labels –check boxes –choices."— Presentation transcript:

1 Applets, Graphical User Interfaces, and Thread / Chapter 9 1 Applet contains GUI components such as –buttons –text fields –labels –check boxes –choices

2 Applets, Graphical User Interfaces, and Thread / Chapter 9 2 GUI Components when GUI components are clicked, dragged, or manipulated, events are triggered

3 Applets, Graphical User Interfaces, and Thread / Chapter 9 3 Panel a container for related GUI components a grouping mechanism

4 Applets, Graphical User Interfaces, and Thread / Chapter 9 4 Button component that triggers a specific action

5 Applets, Graphical User Interfaces, and Thread / Chapter 9 5 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"); pnlName.add(cmdWithdraw); add(pnlName); } continuation Button

6 Applets, Graphical User Interfaces, and Thread / Chapter 9 6 TextField A component that allows input into the program or to display information

7 Applets, Graphical User Interfaces, and Thread / Chapter 9 7 TextField Button cmdWithdraw = new Button("Withdraw"); //add command button to panel pnlButtons.add(cmdWithdraw); add(pnlName); add(pnlButtons ); }} import java.awt.*; import java.applet.*; public class SampleTextField extends Applet{ public void init(){ Panel pnlName = new Panel(); //change color of panel pnlName.setBackground(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);

8 Applets, Graphical User Interfaces, and Thread / Chapter 9 8 Label a component that provides information it is read only

9 Applets, Graphical User Interfaces, and Thread / Chapter 9 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.setBackground(Color.red); Label lblPassWord = new Label("Pass word: "); pnlPassWord.add(lblPassWord); TextField txtPassWord = new TextField(10); pnlPassWord.add(txtPassWord); Panel pnlButtons = new Panel(); pnlButtons.setBackground(Color.black); Button cmdSubmit = new Button("Submit"); pnlButtons.add(cmdSubmit); add(pnlLogin); add(pnlPassWord); add(pnlButtons); }}

10 Applets, Graphical User Interfaces, and Thread / Chapter 9 10 Check Box offers a set of choices any number of check boxes can be selected Check box

11 Applets, Graphical User Interfaces, and Thread / Chapter 9 11 Options offers a set of exclusive choices only one option can be selected Check box

12 Applets, Graphical User Interfaces, and Thread / Chapter 9 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.add(chkOranges); Checkbox chkPears = new Checkbox ("pears"); pnlCheck.add(chkPears); Panel pnlOption = new Panel(); pnlOption.setBackground(Color.red); Choice optGender = new Choice(); optGender.add("Female"); optGender.add("Male"); pnlOption.add(optGender); add(pnlCheck); add(pnlOption); }}


Download ppt "Applets, Graphical User Interfaces, and Thread / Chapter 9 1 Applet contains GUI components such as –buttons –text fields –labels –check boxes –choices."

Similar presentations


Ads by Google