GUI Programming Flashcards
In general, how are GUI windows created?
By extending the JFrame
What is the hierarchy of GUI components?
In the case of the button:
javax. swing.JBUtton
javax. swing.AbstractButton
javax. swing.JComponent
javax. awt.Container
java. awt.Component
How do components keep track of event handlers?
They have a list (listenerList) of references to objects that handle the respective event listener.
New references can be added with addActionListener etc.
What class displays standard dialog boxes?
JOptionPane
What layout manager is used to create grids?
GridBagLayoutManager
How is scrolling implemented?
By putting the components inside a JScrollPane i.e. add(new JScrollPane(component))
What GUI component is used to show images?
Generally a JLabel with ImageIcon is used
How are mouse events handled?
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.
What are the rules for anonymous inner classes?
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