• Tidak ada hasil yang ditemukan

Programming in Java

N/A
N/A
Protected

Academic year: 2024

Membagikan "Programming in Java"

Copied!
6
0
0

Teks penuh

(1)

Programming in Java

CBCS BHCS03

By Parul Chachra

(2)

Chapter 26

Using AWT Controls, Layout Managers, and Menus

Reference: Schildt, H. Java: The Complete Reference. 7th ediJon. McGraw-

Hill EducaJon

(3)

AWT Controls

•  Controls are components that allow a user to

interact with your applicaJon for example, push buQon.

•  Layout manager automaJcally posiJons components within a container

•  Thus, the appearance of a window is determined by a combinaJon of the controls that it contains and the layout manager used to posiJon them.

•  Menu bar : Each entry in a menu bar acJvates a drop-down menu of opJons from which the user can choose. As a general rule, a menu bar is

posiJoned at the top of a window.

(4)

AWT Control Fundamentals

•  The AWT supports the following types of controls (These controls are subclasses of Component):

– Labels

– Push buQons – Check boxes – Choice lists – Lists

– Scroll bars – Text EdiJng

(5)

Adding and Removing Controls

•  To add a control in a window, create an instance of the desired control and then add it to a window by calling add( ), which is defined by Container class

•  One of the form is -

Component add(Component compRef)

•  Here, compRef is a reference to an instance of the control that you want to add

•  A reference to the object is returned.

•  To remove a control from a window call remove( ). This method is also defined by Container

•  Here is one of its forms:

void remove(Component compRef)

•  compRef is a reference to the control you want to remove.

•  To remove all controls, call removeAll( )

(6)

Responding to Controls

•  Except for labels, which are passive, all controls generate events when they are accessed by the user

•  For example, when the user clicks on a push

buQon, an event is sent that idenJfies the push buQon

•  In general, your program simply implements the appropriate interface and then registers an event listener for each control that you need to

monitor

•  Once a listener has been installed, events are automaJcally sent to it

Referensi

Dokumen terkait

11 shows the cumulative distribution functions of the average RMSE location error of the algorithms for various antenna mode conigurations when the range errors

who were chosen to be interviewed are students who participated actively in the group discussion but became passive when classroom discussion was held. They were also chosen when

A survey conducted by Li (2009) reveals that when participants independently learn materials, teachers/instructors supports are still in high requirements. A main session of

Aims relating to harm reduction that are readily identifiable within user involvement and organising include: responding to public health threats; improving the accessibility and

When buying stair lifts there are factors which should be considered by the user to ensure that the stair lift purchase is the right one not only for the user but also to correctly

(2) What language features are frequently used by men and women when responding to e-mail postings from same-gender or cross-gender participants in “Yahoo” discussion groups. As

FileReader is a class or object that is used to read files, and should be utilized with the BufferedFileReader object, which is going to help save data when reading

 Due to the way web authentication is handled (i.e., using a cached credential), http requests will look as if they come from the legitimate user if they are logged in when