+ * @param seq The sequence that the program is operating on.
+ */
+ public MooGUI(Sequence seq) {
+ super("Moosique");
+
+ this.seq = seq;
+ advanceStatus();
+
+ Container pane = getContentPane();
+ pane.setLayout(new BoxLayout(pane, BoxLayout.Y_AXIS));
+
+ // Adds menu bar.
+ menu = new MooMenu();
+ setJMenuBar(menu);
+ advanceStatus();
+
+ // Adds toolbar.
+ toolbar = new MooToolbar();
+ pane.add(toolbar, BorderLayout.NORTH);
+ advanceStatus();
+
+ // Adds main view.
+ view = new MooView(seq.getTracks());
+ pane.add(view, BorderLayout.CENTER);
+
+ // Adds status bar.
+ statusBar = new JLabel("Welcome to Moosique!", JLabel.CENTER);
+ statusBar.setFont(FONT);
+ pane.add(statusBar, BorderLayout.SOUTH);
+
+ // Brings on the colors!
+ setBackground(pane);
+ setBackground(menu);
+ setBackground(toolbar);
+ setBackground(view);
+
+ // Creates timer.
+ timer = new java.util.Timer();
+
+ // Sets up global key listener.
+ ActionMap am = getRootPane().getActionMap();
+
+ Action playAction = new AbstractAction() {
+ public void actionPerformed(ActionEvent ae) {
+ if (!Moosique.getSequencer().isRunning()) {
+ Moosique.play();
+ } else {
+ Moosique.stop();
+ }
+ }};
+ am.put("Play", playAction);
+ am.put("Change octave up", createOctaveAction(true));
+ am.put("Change octave down", createOctaveAction(false));
+
+ InputMap im = getRootPane().getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
+ KeyStroke playKey = KeyStroke.getKeyStroke(KeyEvent.VK_SPACE, 0);
+ KeyStroke octaveUpKey = KeyStroke.getKeyStroke(KeyEvent.VK_F9, 0);
+ KeyStroke octaveDownKey = KeyStroke.getKeyStroke(KeyEvent.VK_F10, 0);
+ im.put(playKey, "Play");
+ im.put(octaveUpKey, "Change octave up");
+ im.put(octaveDownKey, "Change octave down");
+ advanceStatus();
+
+ // Configures window.
+ addWindowListener(new MooGUICloser());
+ pack();
+ setIconImage(logo);
+ Dimension bounds = Toolkit.getDefaultToolkit().getScreenSize();
+ setSize(bounds.width,bounds.height - 28);
+ setLocation(0, 0);
+ setBackground(Color.white);
+ advanceStatus();
+ setVisible(true);
+ show();
+ }
+
+ /**
+ * Sets the background on Containers
+ * @param c the Container that will have it's background change