Intro to Gui and Swing Flashcards
Layout Manager
- Asks components for their preferred size, before making a decision about the layout
- Control the size and location of components nested within other components
Component
A correct term for what we’ve been calling a widget. The things you put in a GUI. The things a user sees and interacts with
Border layout
- The default layout manager for a frame
2. Let’s you add a component to one of five regions
Flow layout
- The default layout manager for a panel
- Gives components their preferred size in both dimensions
- Places components left to right, top to bottom, in the order they were added
Box layout
- The default layout manager for a frame
2. Let’s you align components stacked vertically, even if they could fit side-by-side
background component
- When you add a component to another component
2. The added component is controlled by the layout manager of the background component
How come you can’t add directly to a frame the way you can to a panel?
A JFrame is special because it’s where the rubber meets the road in making something appear on the screen
What if I want a different preferred size? Is there a setSize() method for components?
Yes, there is a setSize(), but the layout manager will ignore it
Can I turn the layout managers off?
Yes. On a component by component basis, you can call setLayout(null)
setLayout()
To allow a panel to use something other than flow
JTextArea
Input more than one line of text
JFrame
The object that represents a window on the screen. It’s where you put all the interface things like buttons, checkboxes, text fields, and so on
Will a button look like a Windows button when you run on Windows?
If you want it to. The standard Java look and feel, also known as Metal, and the native look and feel for your platform
Event-handling
The process of getting and handling a user event
Listener interface
The bridge between the listener and event source