Exam Preparation Elliot Flashcards
Benefits of AWT
Good for background system specific code
Benefits of Swing
Lightweight, pure java, subclass of AWT Frame
What is a JOptionPane
Popup box with Y, N, and Cancel
What is the general structure of. JMenuBar
JMenuBar(JMenu(JMenuItem))
Was is JFrame a subclass of, and what is it not a component of
AWT.frame, JFrame is not a Component
What is a general overview of MVC
View passes input to Controller, Controller updates the View
Controller changes the state of the Model
ModelChanged by the Model updates the values in the view
What parts are in the event dispatch thread
Event Queue, Event Loop, Event handler (click > data received > refresh the gui), GUI components
What part is in the helper thread and where does it send its data
Long task processing, this will add to the event queue
What is an event source
A component generating an event (“fires”)
What is an event
A user interaction
What is an eventListener
An object implementing a handler to react to an complete a task (listeners need to be registered to a source)
What is the general form of a listener
JObject created
name.addActionListener(new actionListener() {
override ActionPerformed(actionEvent e) {
name.method();
}
});
add the object to the panel
What is the mouse listener called
MouseMotionListener
What is the difference between Adaptors and Listeners
Listeners are interfaces, Adaptors are abstract classes
Adaptors only require implementation of the required events
What is the general form of an adaptor
panel.add(new MouseAdaptor() { override the MouseMoved(MouseEvent arg0) { doStuff... } });
What does the Event dispatch thread do
Executes GUI code
What are the three reasons to have the Event dispatch thread
Responsive, long computations won’t lock up the GUI
ThreadSafe, only the EDT can access the GUI
Swing can use SwingWorker to deal with computational tasks
How to use SwingUtilities, what will this ensure
Use invokeLater on runnable as a parameter to start the GUI, this will ensure GUI is on the EDT