+ 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
+ */
+ private void setBackground(Container c) {
+ c.setBackground(bgColor);
+ Component[] comps = c.getComponents();
+ for (int i = 0; i < comps.length; i++) {
+ comps[i].setBackground(bgColor);
+ }
+ }
+
+ /**
+ * Changes the sequence of the GUI.
+ * @param sequence the MIDI sequence to visualize
+ */
+ public void setSequence(Sequence sequence, File file) {
+ seq = sequence;
+ if (file != null) setTitle("Moosique - " + file.getName());
+ else setTitle("Moosique");
+ view.setTracks(seq.getTracks(), true);
+ toolbar.resetProgInd();