Thursday 5 October 2017

CBSE Class 12 - Informatics Practices - Java GUI Programming - Revision Tour-2 (Q & A)

Java GUI Programming - Revision Tour-2
(Q & A)

CBSE Class 12 - Informatics Practices - Java GUI Programming - Revision Tour-2  (Q & A)

Questions and Answers


Q: What is Netbeans? Write about its three important features.

Answer: Netbeans is an open source, Integrated Development Environment (IDE) tool for developing Java applications. 

1. Its a RAD (rapid application development) tool that allows us to develop applications by dragging and positioning GUI components from a palette onto a container.

2. Its GUI builder automatically takes care of the correct spacing and alignment of the different components relative to each other.

3. It has in built support for Java Compiler, interpreter and debugger.

4. It has in built text editor with syntax highlighting.


Q: What is JFrame? 

Answer: The JFrame acts as a container for the elements like the Jlabel, JButton, JTextArea and allows direct editing of their associated properties at the design time and run time.


Q: What is a GUI Builder in Netbeans?

Answer: It is an area to place components on the form visually. There are two views of the GUI builder- the Design View and the Source View. We can switch over from one view to another by simply clicking on the source and design tabs directly above the Design Area.


Q: What is Pallete in Netbeans IDE?

Answer: Palette contains controls or components used to create GUI applications.


Q: What is the function of Inspector Window?

Answer: This window is used to display a hierarchy of all the components or controls placed on the current form.


Q: What is the use of Properties Windows in Netbeans IDE?

Answer: Using this window we can make changes in the properties of currently selected control on the form.


Q: What are components in Java GUI programming? Name the two categories it has been divided into?

Answer:  Components (also known as "widgets") are the basic interface elements the user interacts 
with: jlabels, jbuttons, jtextfields etc. Components are placed on a container (like the 
jFrame). There are two types of controls:

1. Parent or container controls: They act as a background for other controls. For example- JFrame, JPanel etc.

2. Child controls: controls placed inside a container control are called child controls. For example-Text Field, Label, Button etc.


Q: How is appearance and behaviour of GUI components controlled?

Answer: Through their properties and methods.


Q: Describe about the following properties of Jframe?
a) defaultCloseOperation
b) Title

Answer:

a) defaultCloseOperation
Sets action to be performed when the user attempts to close the form.

b) Title
Sets the text to be displayed in the Title bar of the form window.


Q: What are the uses of properties of GUI objects?

Answer: Properties of an object are used to specify its appearance on the form. For example to 
set the background colour of a textfield you change its background property; to set its font you change its font property; and so on.


Q: What is the purpose of 'Methods' of GUI components? Name the two categories 'Methods' are broadly categorised?

Answer: Methods are used to perform some action on the object. For example to display 
something in a textfield you can use its setText() method, to extract the contents of a textfield you can use its getText() method. 
Methods can be divided into two categories- getters and setters.


Q: What are getters? Give two examples.

Answer: Getters are the methods which extract some information from the object and return it to the program. Getters start with the word get. 

Examples of getters are: getText(), getForeground(), getModel(), isEditable etc.


Q: What are setters? Give two examples.

Answer: Setters are the methods which set some properties of the object so that the object's appearance changes. Setters start with the word set. 
Examples of setters are: setText(), setForground(), setModel() etc.


Q: What are events? Give an example of an event generated by a JAVA GUI application.

Answer: Events are the actions which are performed on controls. When the user performs any action on a control, an event happens and that event invokes (sends a call to) the corresponding part 
of the code and the application behaves accordingly.

Examples of events are: mouseClick, mouseMoved,keyPressed etc.


Q: Differentiate between jLabel and jTextField

Answer:
jLabel:
1. jLabel provides text instructions or information.
2. It displays a single line of read-only text, an image or both text and image/icon.

JTextField:
1. It allows editing/displaying of a single line of text.
2. jTextField is an input area where the user can type in characters.


Q: Describe the use of the following properties of  jTextField.
a. Background
b. Border
c. editable
d. enabled
e. font
f. foreground
g. horizontalAlignment
h. text
i. text
j. toolTipText

Answer
a. Background: Sets the background color.

b. Border: Sets the type of border that will surround the text field.

c. editable: If set true user can edit textfield. Default is true.

d. enabled: Contains enabled state of component- True if enabled else false.

e. font: Sets the font.

f. foreground: Sets the foreground color.

g. horizontalAlignment: Sets the horizontal alignment of text displayed in the 
textField.

h. text: Sets the display text

i. toolTipText: Sets the text that will appear when cursor moves over the component.






No comments:

Post a Comment

We love to hear your thoughts about this post!

Note: only a member of this blog may post a comment.