Use LEFT and RIGHT arrow keys to navigate between flashcards;
Use UP and DOWN arrow keys to flip the card;
H to show hint;
A reads text to speech;
29 Cards in this Set
- Front
- Back
What's the difference between procedural programming and event-driven programming? |
Procedural Programs: Program runs from top to bottom of code. |
|
What's the difference between "heavyweight" components of the JDK1.0/1.1 versions and the "lightweight" Swing components of Java 1.2? |
1.0/1.1: Lowest common denominator components that were supported by all OS's Java would run on at the time. Heavyweight because of how heavily they depended on the platform to render windows components on the screen. Different look and feel on each platform. |
|
Concept of container object, what it is used for, and some examples of container objects in the Swing library. |
To hold components such as buttons, labels, textfields etc. We need to hold them in a container object. Three examples include:
|
|
Concept of component objects, what they are used for and some examples we have used |
Components are to be interacted with by the user running the program. Examples Include: |
|
Basic Anatomy of the Swing JFrame Object |
From Top to bottom |
|
How to create a JFrame object of a given size and set its title bar text. |
import javax.swing.*; public class Whatever public static void main(String[] args){ JFrame frame1 = new Jframe("I've been Framed!"); frame1.setSize(x,y) frame1.setLocation(x,y) frame1.setVisable(true); } } |
|
Difference between JFrame and JPanel |
JFrame: Commonly used for stand alone applications. Needs inner frames for different operations/purposes |
|
How to add JButtons to JFrame or JPanel |
//Make Button JButton redBtn = new JButton("Red"); |
|
What is an anonymous component object, and how might we add one to a container? |
A component without being identified with a variable |
|
How do you size and centre a JFrame in the middle of the monitor? |
this.setSize(x, y); this.setLocationRelativeTo(null); |
|
How the screen co-ordinate system works, and how it is used to position objects on the monitor? |
(0,0) starts at the top left and to the right and down from there. |
|
How does the RGB 24 bit color model work to create different colors? |
Each color is represented by 8 bits (R,G,B) |
|
What is a memory leak, and how is Java set up to avoid them? |
Triggered from Garths C class |
|
How does one ensure that one closes a JFrame, so it does not stay in memory? |
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); |
|
What is a layout manager, and what is it used for? |
Layout managers arrange and position components within the frame/panel |
|
What are the benefits of using a layout manager to position components within a container? |
Looks ok on different resolutions and resizing, |
|
How do you create a layout manager object and assign it to a container object? |
this.setLayout(new GridLayout()); |
|
Three examples of layout managers we have used in class code and describe how each one arranges components in a container |
Flowlayout: Arranged from left to right and top to bottom GridLayout: Specify grid of rows and columns, components will fill a row before starting the next one |
|
How does the event delegation model work with components in the Swing classes of Java? |
It means the component itself is not responsible for handling an event, and it is instead to an event handler. |
|
What is the difference between a source object and an event handler? |
The source is a component or container that is being changed or interacted with, the event handler is the object that waits for that interaction to occur and creates the action based on how the event is defined. |
|
What exactly is an event in Java and how does it originate? |
The event is an object that is created when the user does something like press a JButton. |
|
What is a listener, and what does it do? |
An object that gets assigned to a component to define and handle events. |
|
Event Object examples, namely ActionEvent, MouseEvent, ChangeEvent, KeyEvent |
ActionEvent: Jbutton press, radioButton selection MouseEvent: Mouse push, release ChangeEvent: Changes in components (text in box changed etc.) ??? KeyEvent: Key Presses/Combinations |
|
How does one register a listener for a component, such as a JButton, JTextField, JSlider, JMenu, JPanel or JFrame? |
MaryPoppins btnListener = new MaryPoppins(); private class MaryPoppins implements ActionListener { public void actionPerformed(ActionEvent ev) {
|
|
What is an adapter class and how is it useful to the coder? |
Stolen from Dan Maclam without permission:Adapter is a pattern that provides default (often empty) implementation of interface or abstract class. For example MouseAdapter provides empty implementation of MouseListener interface. |
|
What is an inner class used for, and how do we avoid scope problems when using inner classes as event handlers? |
I think we only used them for ActionListeners in our examples. To avoid scope problems, just declare in classwide scope in the outer class. |
|
Explain the three coding options for handling events: using the host class, writing an inner class, or using an anonymous inner class |
Is there really anything else here to explain? |
|
What is the difference between how JRadioButtons work as compared to JCheckBoxes |
Radio buttons are mutually exclusive and need a button group, while you can select more than one check box. |
|
What is logical grouping of JRadioButtons, and what is it used for? |
It is to make sure that JRadioButtons are mutually exclusive and only one can be selected |