Most of these are event sources meaning the Swing components.
Java Swing
———-
javax.swing.JComponent
All the components are capable of nesting. You can stick anything to anything.
Replay
4 steps to make a gui
1) make a frame
2) make a button
3) add the button to frame
4) display
interactive components
button
check box
text field
background components
frame
panel
Layout Manager, is a Java Object associated with a particular component. Each Component will have its Layout Manager.Layout Manager is applicable to components that can hold other components. for example button will not have a layout manager because it does not hold any components.
nested layouts.
JPanel panela = new JPanel ();
JPanel panelb = new JPanel ();
panelb.add(new JButton(“button 1”));
panelb.add(new JButton(“button 2”));
panelb.add(new JButton(“button 3)));
panelA.add(panelb);
border layout is the default manager for frame, it has five regions and it is fixed. one component per region.
flow layout is the default manager for panel, it works like a word processor . it arranges all the components to the size
specified.
box layout is quite similar to flow layout with additional features like you can have a component return key and force a component to start a new line
we can turn off the layout manager by saying setLayout(null) and then its up to you
to hard code the exact screen location and dimension of the component.
next page 447
More in next part.
References:
Head First Java 2nd Edition