Commit 956a819a authored by Trisha Gee's avatar Trisha Gee
Browse files

[Ch15] Code for the first layout example screenshot

parent 64c6bfec
Loading
Loading
Loading
Loading
+9 −7
Changes for src/main/java/ch15/SwingExamples.java: 9 added lines, 7 removed lines.
Original line number Diff line number Diff line
@@ -8,15 +8,17 @@ public class SwingExamples {
    JFrame frame = new JFrame();
    JButton button = new JButton("click me");

    Box box = new Box(BoxLayout.Y_AXIS);
    box.add(button);
    box.add(new JCheckBox("choose me"));

    frame.getContentPane().add(BorderLayout.EAST, box);
    JCheckBox checkBox = new JCheckBox("choose me");
    JMenuBar menuBar = new JMenuBar();
    menuBar.add(new JMenu("File"));
    menuBar.add(new JMenu("Panic"));
    menuBar.add(new JMenu("Deviate"));
    frame.add(BorderLayout.NORTH, menuBar);

    Box textBox = new Box(BoxLayout.X_AXIS);
    textBox.add(new JTextField("this is a text field"));
    frame.getContentPane().add(BorderLayout.NORTH, textBox);
    textBox.add(button);
    textBox.add(checkBox);
    frame.getContentPane().add(BorderLayout.CENTER, textBox);

    frame.setSize(300,300);
    frame.setVisible(true);