]> ruin.nu Git - moosique.git/blobdiff - MooGUI.java
minor updates..
[moosique.git] / MooGUI.java
index f0c108ae7a800831ecc371584081433c34fc29d6..7bcd6dd854d103d8360c78f1396ad0c9dde62eae 100644 (file)
@@ -9,10 +9,11 @@ import java.awt.event.*;
  * @author  Mikael Andreen
  */
  
-public class MooGUI extends JFrame implements WindowListener {
+public class MooGUI extends JFrame {
 
        private Sequence seq;
 
+       private MooToolbar toolbar;
        private JPanel trackPanel;
        private MooTrackView[] trackViews;
        private JLabel statusBar;
@@ -28,14 +29,14 @@ public class MooGUI extends JFrame implements WindowListener {
                this.seq = seq;
                
                Container pane = getContentPane();
-               pane.setLayout(new BorderLayout());
+               pane.setLayout(new BoxLayout(pane, BoxLayout.Y_AXIS));
                
                // Adds menu bar.
                setJMenuBar(new MooMenu());
 
                // Adds toolbar.
-               pane.add(new MooToolbar(), BorderLayout.NORTH);
-               addWindowListener(this);
+               toolbar = new MooToolbar();
+               pane.add(toolbar, BorderLayout.NORTH);
 
                // Adds tracks.
                trackPanel = new JPanel(true);
@@ -46,13 +47,13 @@ public class MooGUI extends JFrame implements WindowListener {
                statusBar = new JLabel("Welcome to Moosique!", JLabel.CENTER);
                pane.add(statusBar, BorderLayout.SOUTH);
 
-               addWindowListener(this);
+               addWindowListener(new MooGUICloser());
                pack();
-               Dimension bounds = new Dimension(400,300);
-               setSize(bounds.width,bounds.height);
-               setLocation((Toolkit.getDefaultToolkit().getScreenSize().width / 2) - (bounds.width / 2), (Toolkit.getDefaultToolkit().getScreenSize().height / 2) - (bounds.height / 2));
+               Dimension bounds = Toolkit.getDefaultToolkit().getScreenSize();
+               setSize(bounds.width,bounds.height - 40);
+               setLocation(0, 0);
                // setResizable(false);
-               // setBackground(Color.white);
+               setBackground(Color.white);
                setVisible(true);
                show();
        }
@@ -74,21 +75,22 @@ public class MooGUI extends JFrame implements WindowListener {
                statusBar.setText(text);
        }
        
+       /** 
+        * Fills the track panel with track views for all tracks in the current sequence.
+        */
        private void createTrackViews() {
                trackPanel.removeAll();
                Track[] tracks = seq.getTracks();
+               trackPanel.setLayout(new GridLayout(1, tracks.length));
                trackViews = new MooTrackView[tracks.length];
                for (int i = 0; i < tracks.length; i++) {
                        trackViews[i] = new MooTrackView(tracks[i]);
                        trackPanel.add(new MooTrackView(tracks[i]));
                }
+               trackPanel.validate();
        }
-
-       public void windowOpened(WindowEvent e) {}
-       public void windowClosing(WindowEvent e) {Moosique.quit();}
-       public void windowClosed(WindowEvent e) {}
-       public void windowIconified(WindowEvent e) {}
-       public void windowDeiconified(WindowEvent e) {}
-       public void windowActivated(WindowEvent e) {}
-       public void windowDeactivated(WindowEvent e) {}
-}
+       
+       class MooGUICloser extends WindowAdapter {
+               public void windowClosing(WindowEvent e) {Moosique.quit();}
+       }
+}
\ No newline at end of file