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.getTracks());
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);
59 addWindowListener(new MooGUICloser());
61 Dimension bounds = Toolkit.getDefaultToolkit().getScreenSize();
62 setSize(bounds.width,bounds.height - 40);
64 // setResizable(false);
65 setBackground(Color.white);
70 private void setBackground(Container c) {
71 c.setBackground(bgColor);
72 Component[] comps = c.getComponents();
73 for (int i = 0; i < comps.length; i++) {
74 comps[i].setBackground(bgColor);
79 * Changes the sequence of the GUI.
80 * @param sequence the MIDI sequence to visualize
82 public void setSequence(Sequence sequence) {
84 view.update(seq.getTracks());
88 * Shows the given message in the status bar.
89 * @param text the message to show
91 public void setStatus(String text) {
92 statusBar.setText(text);
95 class MooGUICloser extends WindowAdapter {
96 public void windowClosing(WindowEvent e) {