AJP Course Assignment 2

Choose a study mode

Play Quiz
Study Flashcards
Spaced Repetition
Chat to Lesson

Podcast

Play an AI-generated podcast conversation about this lesson
Download our mobile app to listen on the go
Get App

Questions and Answers

In which package are Swing components defined?

  • javax.swing (correct)
  • javax.java.swing
  • java.javax.swing
  • javax.applet.swing

The super class of all swing buttons is –

  • JButton
  • ButtonGroup
  • AbstractButton (correct)
  • Button

Which of the following alignment is not possible for JLabel?

  • LEFT
  • TOP (correct)
  • LEADING
  • CENTER

Alignment constants of JLabel are part of –

<p>SwingConstants class (C)</p> Signup and view all the answers

How will you set an icon for the JLabel?

<p>Using setIcon() method (C)</p> Signup and view all the answers

Swing's text field is encapsulated by –

<p>JComponent class (B)</p> Signup and view all the answers

How to give number of columns for JTextField?

<p>Use setColumns() method (B)</p> Signup and view all the answers

What is the return type of getText() method of JButton class?

<p>String (D)</p> Signup and view all the answers

How will you assign the string and icon both to the JButton?

<p>Initialize them directly in the constructor (B)</p> Signup and view all the answers

Which event is generated when a JButton is pushed?

<p>ActionEvent (D)</p> Signup and view all the answers

Immediate super class of JCheckBox is –

<p>JComponent (C)</p> Signup and view all the answers

The constructor JCheckBox(true, 'YES') suggests that –

<p>Checkbox is selected and displays the string 'YES' on it (A)</p> Signup and view all the answers

When JCheckBox is clicked, which event is generated?

<p>ItemEvent (C)</p> Signup and view all the answers

How can we create Radio buttons?

<p>Using JRadioButton class (B)</p> Signup and view all the answers

How to make the group of Radio buttons?

<p>Using ButtonGroup class (D)</p> Signup and view all the answers

How to put the contents of the whole vector into the JComboBox?

<p>Use the constructor of JComboBox (A)</p> Signup and view all the answers

How to prevent the drop-down list of JComboBox?

<p>It is not possible (A)</p> Signup and view all the answers

Which method is used to define the tabs in the tabbed pane?

<p>addTab() (B)</p> Signup and view all the answers

The scroll bar constants for scroll pane are defined in –

<p>ScrollPaneConstants class (C)</p> Signup and view all the answers

Which of the following constants shows scroll bars always?

<p>HORIZONTAL_SCROLLBAR_ALWAYS (A)</p> Signup and view all the answers

JScrollPane is an immediate sub-class of –

<p>JComponent (B)</p> Signup and view all the answers

Is it possible to add an array of objects to trees? How?

<p>Yes, using one of its constructor forms (D)</p> Signup and view all the answers

Which items can't we directly add to JTree using its constructor?

<p>Array of objects (C)</p> Signup and view all the answers

When a tree is expanded, which event is generated?

<p>TreeExpansionEvent (D)</p> Signup and view all the answers

Which method is used to translate a mouse click on a specific point of the tree to a tree path?

<p>getPathForLocation() (D)</p> Signup and view all the answers

The TreeNode is –

<p>A class (B)</p> Signup and view all the answers

The TreeExpansionEvent class is defined in –

<p>javax.swing.event package (B)</p> Signup and view all the answers

The TreeExpansionListener interface provides the following method –

<p>treeExpanded() (B)</p> Signup and view all the answers

Flashcards are hidden until you start studying

Study Notes

Swing Components and Classes

  • Swing components are defined in the javax.swing package.
  • The superclass of all Swing buttons is AbstractButton.
  • JLabel cannot have a TOP alignment option; only LEFT, CENTER, and LEADING are valid alignments.
  • Alignment constants for JLabel are part of the SwingConstants interface.

JLabel and JTextField

  • To set an icon for JLabel, use the setIcon() method.
  • Swing's text field is encapsulated by the JTextComponent class.
  • Number of columns for JTextField can be defined using the setColumns() method or directly within the constructor.

JButton Functionalities

  • The return type of getText() method from the JButton class is String.
  • To assign both string and icon to a JButton, use the setIconText() method.
  • Pushing a JButton generates an ActionEvent.

JCheckBox and Radio Buttons

  • The immediate superclass of JCheckBox is JToggleButton.
  • Constructor JCheckBox(true, "YES") indicates that the checkbox is selected and displays "YES".
  • Clicking a JCheckBox generates an ItemEvent.
  • Radio buttons are created using the JRadioButton class and grouped with the ButtonGroup class.

JComboBox and ScrollPane

  • To add content from a whole vector into a JComboBox, use the JComboBox constructor.
  • To prevent a JComboBox drop-down list, use a method specifically created for prevention or effects within the constructor.
  • Tabs in the tabbed pane are defined using the addTab() method.
  • Scroll bar constants for a scroll pane are defined in the ScrollPaneConstants class.
  • HORIZONTAL_SCROLLBAR_ALWAYS shows horizontal scroll bars at all times.

JScrollPane and JTree

  • JScrollPane is an immediate subclass of JComponent.
  • Adding an array of objects to trees is possible using a specific form of the constructor.
  • Directly adding arrays to JTree using its constructor is not possible, while vectors and hash tables can be added.
  • Expanding a tree generates a TreeExpansionEvent.

TreeNode and Event Handling

  • TreeNode is an interface.
  • The TreeExpansionEvent class is defined in the javax.swing.event package.
  • The TreeExpansionListener interface includes the treeExpanded() method.

Miscellaneous

  • Handling mouse clicks on a specific point of the tree can be interpreted to a tree path using the getPathForLocation() method.

Studying That Suits You

Use AI to generate personalized quizzes and flashcards to suit your learning preferences.

Quiz Team

Related Documents

AJP-2_Ans.pdf

More Like This

Use Quizgecko on...
Browser
Browser