GUI Programming Flashcards

1
Q

In general, how are GUI windows created?

A

By extending the JFrame

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

What is the hierarchy of GUI components?

A

In the case of the button:

javax. swing.JBUtton
javax. swing.AbstractButton
javax. swing.JComponent
javax. awt.Container
java. awt.Component

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

How do components keep track of event handlers?

A

They have a list (listenerList) of references to objects that handle the respective event listener.

New references can be added with addActionListener etc.

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

What class displays standard dialog boxes?

A

JOptionPane

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

What layout manager is used to create grids?

A

GridBagLayoutManager

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

How is scrolling implemented?

A

By putting the components inside a JScrollPane i.e. add(new JScrollPane(component))

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

What GUI component is used to show images?

A

Generally a JLabel with ImageIcon is used

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

How are mouse events handled?

A

MouseMotionAdapter and MouseAdapter are abstract classes that have a range of methods. These usually just return null.

These can be overdid, such as mouseClicked(MouseEvent e) and mouseMoved(MouseEvent e), in an anonymous class.

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

What are the rules for anonymous inner classes?

A

They are by definition instantiated by the code of the outer class.

All members (even private) of the outer class are in scope. Therefore they may be shadowed.

The keyword ‘this’ refers to the instance of the inner class. To refer to the outer class, use C.this where C is the outer class name

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