JAVA Beginners part 16

t2t1

t3t4

Most of these are event sources meaning the Swing components.

test.jpg

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);

text.jpg

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

sample 6.jpg

sample7.jpg

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.

test1.jpg

 

next page 447

More in next part.

References:

Head First Java 2nd Edition

textarea

beatbox

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s