Unit 4: Java GUI Flashcards

1
Q

What is Java’s main library for building GUIs?

A

Swing (which builds on the older AWT - Abstract Window Toolkit)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Which classes must be imported for GUI development?

A

import java.awt.; import java.awt.event.; import javax.swing.*;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is a container in Java GUI?

A

A component that holds and displays other GUI components (like buttons, text fields).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What class represents a window in Java Swing?

A

JFrame

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is a JButton used for?

A

A clickable button that can trigger an ActionEvent.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is a JTextField?

A

A field that displays text and can be used for input/output.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

How do you add a component to a JFrame?

A

Use window.add(component); where window is the content pane.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What layout manager arranges components left-to-right, top-to-bottom?

A

FlowLayout

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What interface must be implemented for handling button clicks?

A

ActionListener

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What method is required when implementing ActionListener?

A

public void actionPerformed(ActionEvent e)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

How do you register a button for event handling?

A

button.addActionListener(this);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

How do you check which button triggered an event?

A

if (e.getSource() == buttonName)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly