1 import javax.sound.midi.*;
4 import java.awt.event.*;
7 * Moosique's graphical user interface.
9 * @author Einar Pehrson
12 public class MooGUI extends JFrame {
16 private MooToolbar toolbar;
18 private JLabel statusBar;
19 public static final Font FONT = new Font("Helvetica", Font.PLAIN, 10);
20 public static final Color bgColor = new Color(192, 224, 255);
25 public MooGUI(Sequence seq) {
30 Container pane = getContentPane();
31 pane.setLayout(new BoxLayout(pane, BoxLayout.Y_AXIS));
38 toolbar = new MooToolbar();
39 pane.add(toolbar, BorderLayout.NORTH);
42 view = new MooView(seq);
43 pane.add(view, BorderLayout.CENTER);
46 statusBar = new JLabel("Welcome to Moosique!", JLabel.CENTER);
47 statusBar.setFont(FONT);
48 pane.add(statusBar, BorderLayout.SOUTH);
50 // Brings on the colors!
53 setBackground(toolbar);
55 statusBar.setBackground(bgColor);
56 view.setBackground(bgColor);
58 ActionMap am = getRootPane().getActionMap();
60 Action playAction = new AbstractAction() {
61 public void actionPerformed(ActionEvent ae) {
62 Moosique.resumepause();
64 am.put("play", playAction);
66 InputMap im = getRootPane().getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
67 KeyStroke playKey = KeyStroke.getKeyStroke(KeyEvent.VK_SPACE, 0);
68 im.put(playKey, "play");
72 addWindowListener(new MooGUICloser());
74 Dimension bounds = Toolkit.getDefaultToolkit().getScreenSize();
75 setSize(bounds.width,bounds.height - 40);
77 // setResizable(false);
78 setBackground(Color.white);
83 private void setBackground(Container c) {
84 c.setBackground(bgColor);
85 Component[] comps = c.getComponents();
86 for (int i = 0; i < comps.length; i++) {
87 comps[i].setBackground(bgColor);
92 * Changes the sequence of the GUI.
93 * @param sequence the MIDI sequence to visualize
95 public void setSequence(Sequence sequence) {
97 view.setSequence(seq);
101 * Shows the given message in the status bar.
102 * @param text the message to show
104 public void setStatus(String text) {
105 statusBar.setText(text);
111 public void update(){
113 // Calls on the toolbar to update the progress indicator.
114 //toolbar.updateProgInd();
117 class MooGUICloser extends WindowAdapter {
118 public void windowClosing(WindowEvent e) {