Page 774 - Introduction to Programming with Java: A Problem Solving Approach
P. 774

                740 Chapter 17 GUI Programming—Component Layout, Additional GUI Components
3. [after §17.4] Provide a complete program that is a modification of Chapter 16’s Greeting program. Your new program should use a BorderLayout manager (instead of a FlowLayout manager), and it should generate the following display after a name has been entered. Make the frame size 300 pixels wide and
80 pixels high.
4. [after §17.4] With a BorderLayout, what happens if the east region is empty? Said another way, which region(s), if any, expand(s) if the east region is empty?
5. [after §17.4] Assume you have this program: import javax.swing.*;
import java.awt.*;
public class BorderLayoutExercise extends JFrame
 {
}
// end class BorderLayoutExercise
public BorderLayoutExercise()
{
setTitle("Border Layout Exercise");
setSize(300, 200);
setDefaultCloseOperation(EXIT_ON_CLOSE);
        Apago PDF Enhancer
add(new JLabel("Lisa the label"), BorderLayout.NORTH);
add(new JLabel("LaToya the label"), BorderLayout.CENTER);
add(new JLabel("Lemmy the label"), BorderLayout.SOUTH);
setVisible(true);
// end BorderLayoutExercise constructor
//*******************************************************
}
setLayout(new BorderLayout());
public static void main(String[] args)
{
}
new BorderLayoutExercise();
(a) Specify the changes you would make to the above code to produce this output:
 





































































   772   773   774   775   776