0% found this document useful (0 votes)
51 views

AJP Qans Experiment One

The document provides details about Java programming concepts including AWT components, containers, controls, different types of dialog boxes, layout managers, and constructors for common classes like Button, Label, Checkbox etc. It includes questions to test the reader's understanding and provides explanations for concepts like the difference between a Choice and List, default TextField length, how to add components to a Frame, and more.

Uploaded by

Iqbal Bagwan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
51 views

AJP Qans Experiment One

The document provides details about Java programming concepts including AWT components, containers, controls, different types of dialog boxes, layout managers, and constructors for common classes like Button, Label, Checkbox etc. It includes questions to test the reader's understanding and provides explanations for concepts like the difference between a Choice and List, default TextField length, how to add components to a Frame, and more.

Uploaded by

Iqbal Bagwan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

ADVANCE JAVA PROGRAMMING

Experiment no One
Title:- Write a program to design a form using the component textfield , label, checkbox, button,
list.

9.0 Questions for confirmation of learning.

1] What is difference between choice and List.

Answer:- A Choice is displayed in a compact form that requires you to pull it down to see the list of
available choices. Only one item may be selected from a Choice. A List may be displayed in such a
way that several List items are visible

2] What is default length of textfield.

Answer:- Default length of TextField is 10 character.

3] List the types of Dialog.

Answer:-
Modeless type — A modeless dialog box does not block any other window while it is visible.
Document-Modal type — A document-modal dialog box blocks all windows from the same
document, except windows from its child hierarchy.

4] In which layout we can arrange the components in row and column format.

Answer:- In GridLayout we can arrange the components in row and column.

Conclusion:-

1] To hold components Containers are used

2] To add component we have to write add().

Questions:-

1] What are components and containers?

Containers
Containers hold and organize your Components, but they also contain code for event handling and
many 'niceties' such as controlling the cursor image and the application's icon.
Containers:

 Frame
 Window
 Dialog
 Panel

Component
Components are generally the stuff that the user interacts with. The meat and potatoes of your
application. (as discussed in the Introduction).
List of common Components

 List
 Scrollbar
 TextArea
 TextField

2] What are different awt components?

Answer:-

3] What is procedure to create and add the different awt components.

Answer:-

1. Import java.awt
import java.awt.*;
2. Extending frame or applet
Frame f=new Frame();
3. Set the layout.
f.setlayout(new FlowLayout());
4. Create components
Label l1=new Label(“Name”);
5. Adding the components to the frame or applet
f.add(l1);

4] What is difference between checkbox and checkboxgroup.

Answer:- In check box you can have multiple choice but in case of checkboxgroup button you have
select any one at a time.

5] What is frame and panel.

Answer:- Frame : A resizable, movable window with title bar and close button. Usually it contains
Panels. It is Derived From Window. Default layout is BorderLayout.

Panel : A region internal to a Frame or another Panel. Used for grouping components together. Not
bounded by a visible border. You can change background colour of a panel to delimit it though. Lives
inside some enclosing Container.It is Derived From Container. Default layout is FlowLayout.

6] Write steps to adding component to frame.

Answeer:-
1. Import java.awt
import java.awt.*;
2. Extending frame or applet
Frame f=new Frame();
3. Set the layout.
f.setlayout(new FlowLayout());
4. Create components
Label l1=new Label(“Name”);
5. Adding the components to the frame or applet
f.add(l1);

7] What is control what are different types of control.

Answer:- Controls are components that allow a user to interact with your application.
- A component is a graphical object.

- A few examples of components are:

 Button
 Canvas
 Checkbox
 Choice
 Container
 Label
 List
 Scrollbar
 TextComponent

8] What is difference between textfield and textarea.


Answer:-
Differences between TextField and TextArea

 TextField displays only one line of text of any length. TextArea displays multiple lines of text
of any length.
 TextField generates ActionEvent handled by ActionListener and TextArea generates
TextEvent handled by TextListener.

9] What are different constructors of the button component?


Answer:-

Class constructors
S.N. Constructor & Description

Button()
1
Constructs a button with an empty string for its label.
Button(String text)
2
Constructs a new button with specified label.

10] In which package AWT classes are contained.


Answer:-
import java.awt.*;
11] State the use of button class constructor.

Answer:- The Button class is used to create a labelled button. The application result in some action
when the button is pushed.

Button b1=new Button();

Button b2 new Button(“Click Here”);

12] What is scrollbar and what is its use?

Answer:- The Scrollbar class embodies a scroll bar, a familiar user-interface object. A scroll bar
provides a convenient means for allowing a user to select from a range of values alternatively, a
scroll bar can represent a range of values. For example, if a scroll bar is used for scrolling through
text, the width of the "bubble" (also called the "thumb" or "scroll box") can be used to represent the
amount of text that is visible

13] Write different constructors of label class with its syntax.

Answer:-
Class constructors
S.N. Constructor & Description
Label()
1
Constructs an empty label.
Label(String text)
2
Constructs a new label with the specified string of text, left justified.
Label(String text, int alignment)
3
Constructs a new label that presents the specified string of text with the specified alignment.

14] Write a procedure to create a radio button.

Answer:- The CheckboxGroup class is used to group together a set of Checkbox buttons.
Exactly one check box button in a CheckboxGroup can be in the "on" state at any given time.
Pushing any button sets its state to "on" and forces any other button that is in the "on" state
into the "off" state.

1] create object of CheckboxGroup class

CheckboxGroup lngGrp = new CheckboxGroup();.

2] Using above object of CheckboxGroup Object create radio button.

 Checkbox java = new Checkbox("Java", lngGrp, true);


 Checkbox cpp = new Checkbox("C++", lngGrp, true);
 Checkbox vb = new Checkbox("VB", lngGrp, true);

You might also like