1 import javax.sound.midi.*;
4 import java.awt.event.*;
7 * Moosique's graphical user interface.
9 * @author Mikael Andreen
12 public class MooGUI extends JFrame implements WindowListener {
16 private JPanel trackPanel;
17 private MooTrackView[] trackViews;
18 private JLabel statusBar;
20 public static Font standardFont = new Font("Helvetica", Font.PLAIN, 10);
25 public MooGUI(Sequence seq) {
30 Container pane = getContentPane();
31 pane.setLayout(new BorderLayout());
34 setJMenuBar(new MooMenu());
37 pane.add(new MooToolbar(), BorderLayout.NORTH);
38 addWindowListener(this);
41 trackPanel = new JPanel(true);
43 pane.add(trackPanel, BorderLayout.CENTER);
46 statusBar = new JLabel("Welcome to Moosique!", JLabel.CENTER);
47 pane.add(statusBar, BorderLayout.SOUTH);
49 addWindowListener(this);
51 Dimension bounds = new Dimension(400,300);
52 setSize(bounds.width,bounds.height);
53 setLocation((Toolkit.getDefaultToolkit().getScreenSize().width / 2) - (bounds.width / 2), (Toolkit.getDefaultToolkit().getScreenSize().height / 2) - (bounds.height / 2));
54 // setResizable(false);
55 // setBackground(Color.white);
61 * Changes the sequence of the GUI.
62 * @param sequence the MIDI sequence to visualize
64 public void setSequence(Sequence sequence) {
70 * Shows the given message in the status bar.
71 * @param text the message to show
73 public void setStatus(String text) {
74 statusBar.setText(text);
77 private void createTrackViews() {
78 trackPanel.removeAll();
79 Track[] tracks = seq.getTracks();
80 trackViews = new MooTrackView[tracks.length];
81 for (int i = 0; i < tracks.length; i++) {
82 trackViews[i] = new MooTrackView(tracks[i]);
83 trackPanel.add(new MooTrackView(tracks[i]));
87 public void windowOpened(WindowEvent e) {}
88 public void windowClosing(WindowEvent e) {Moosique.quit();}
89 public void windowClosed(WindowEvent e) {}
90 public void windowIconified(WindowEvent e) {}
91 public void windowDeiconified(WindowEvent e) {}
92 public void windowActivated(WindowEvent e) {}
93 public void windowDeactivated(WindowEvent e) {}