Sidepane.java 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. import java.io.*;
  2. import java.util.*;
  3. import java.awt.*;
  4. import javax.swing.*;
  5. public class Sidepane extends JPanel implements Observer
  6. {
  7. private Model model;
  8. private Colours colours;
  9. private JPanel thiccness;
  10. // Bob the Builder this shit
  11. public Sidepane(Model model)
  12. {
  13. // Hook up this observer so that it will be notified when the model
  14. // changes.
  15. this.model = model;
  16. this.setPreferredSize(new Dimension(100, 300));
  17. colours = new Colours();
  18. this.add(colours);
  19. model.addObserver(this);
  20. }
  21. /**
  22. * Update with data from the model.
  23. */
  24. public void update(Object observable)
  25. {
  26. this.setBackground(model.sideColour);
  27. revalidate();
  28. repaint();
  29. }
  30. }
  31. private class Colours extends JPanel
  32. {
  33. private jButton red;
  34. private jButton green;
  35. private jButton blue;
  36. private jButton yellow;
  37. private jButton purple;
  38. private jButton orange;
  39. private jButton cyan;
  40. private jButton custom;
  41. public colours()
  42. {
  43. this.setLayout(new GridLayout(0, 2));
  44. red = new jButton("Red");
  45. green = new jButton("Green");
  46. blue = new jButton("Blue");
  47. yellow = new jButton("Yellow");
  48. purple = new jButton("Purple");
  49. orange = new jButton("Orange");
  50. cyan = new jButton("Cyan");
  51. custom = new jButton("Custom");
  52. this.add(red);
  53. this.add(green);
  54. this.add(blue);
  55. this.add(yellow);
  56. this.add(purple);
  57. this.add(orange);
  58. this.add(cyan);
  59. this.add(custom);
  60. }
  61. }