Commit adb43f4e authored by Trisha Gee's avatar Trisha Gee
Browse files

[Ch15] Fragments exercise

parent 9e338936
Loading
Loading
Loading
Loading
+0 −1
Changes for src/main/java/ch15/BeatBox.java: 0 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -7,7 +7,6 @@ import java.util.ArrayList;

import static javax.sound.midi.ShortMessage.*;


public class BeatBox {
  private ArrayList<JCheckBox> checkboxList;
  private Sequencer sequencer;
+22 −5
Changes for src/main/java/ch15/ex/Fragments.java: 22 added lines, 5 removed lines.
Original line number Diff line number Diff line
@@ -4,7 +4,7 @@ import javax.swing.*;
import java.awt.*;

public class Fragments {
  void fragmentD() {
  static JFrame fragmentD() {
    JFrame frame = new JFrame();
    JPanel panel = new JPanel();
    panel.setBackground(Color.darkGray);
@@ -13,9 +13,10 @@ public class Fragments {
    frame.getContentPane().add(BorderLayout.NORTH, panel);
    panel.add(buttonTwo);
    frame.getContentPane().add(BorderLayout.CENTER, button);
    return frame;
  }

  void fragmentB() {
  static JFrame fragmentB() {
    JFrame frame = new JFrame();
    JPanel panel = new JPanel();
    panel.setBackground(Color.darkGray);
@@ -24,9 +25,10 @@ public class Fragments {
    panel.add(buttonTwo);
    frame.getContentPane().add(BorderLayout.CENTER, button);
    frame.getContentPane().add(BorderLayout.EAST, panel);
    return frame;
  }

  void fragmentC() {
  static JFrame fragmentC() {
    JFrame frame = new JFrame();
    JPanel panel = new JPanel();
    panel.setBackground(Color.darkGray);
@@ -34,9 +36,10 @@ public class Fragments {
    JButton buttonTwo = new JButton("watari");
    panel.add(buttonTwo);
    frame.getContentPane().add(BorderLayout.CENTER, button);
    return frame;
  }

  void fragmentA() {
  static JFrame fragmentA() {
    JFrame frame = new JFrame();
    JPanel panel = new JPanel();
    panel.setBackground(Color.darkGray);
@@ -45,9 +48,10 @@ public class Fragments {
    panel.add(button);
    frame.getContentPane().add(BorderLayout.NORTH, buttonTwo);
    frame.getContentPane().add(BorderLayout.EAST, panel);
    return frame;
  }

  void fragmentE() {
  static JFrame fragmentE() {
    JFrame frame = new JFrame();
    JPanel panel = new JPanel();
    panel.setBackground(Color.darkGray);
@@ -56,6 +60,19 @@ public class Fragments {
    frame.getContentPane().add(BorderLayout.SOUTH, panel);
    panel.add(buttonTwo);
    frame.getContentPane().add(BorderLayout.NORTH, button);
    return frame;
  }

  static JFrame missing() {
    JFrame frame = new JFrame();
    JPanel panel = new JPanel();
    panel.setBackground(Color.darkGray);
    JButton button = new JButton("tesuji");
    JButton buttonTwo = new JButton("watari");
    frame.getContentPane().add(BorderLayout.SOUTH, button);
    panel.add(buttonTwo);
    frame.getContentPane().add(BorderLayout.CENTER, panel);
    return frame;
  }

}
+16 −0
Changes for src/main/java/ch15/ex/TestLayout.java: 16 added lines, 0 removed lines.
Original line number Diff line number Diff line
package ch15.ex;

import javax.swing.*;

public class TestLayout {
  public static void main(String[] args) {
    new TestLayout().go();
  }

  public void go() {
    JFrame frame = Fragments.missing();

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