1 import javax.sound.midi.*;
4 import java.awt.event.*;
7 * The main view, the container of the track views.
9 * @author Einar Pehrson
12 public class MooView extends JScrollPane {
14 private Track[] tracks;
15 private MooTrackView[] trackViews;
16 private JPanel trackPanel;
19 * Creates the main view
21 public MooView(Track[] tracks) {
22 super(VERTICAL_SCROLLBAR_ALWAYS, HORIZONTAL_SCROLLBAR_AS_NEEDED);
26 trackPanel = new JPanel(new GridLayout(1,3), true);
28 setViewportView(trackPanel);
32 * Fills the track panel with track views for all tracks in the current sequence.
34 private void createTrackViews() {
35 trackPanel.removeAll();
36 ((GridLayout)trackPanel.getLayout()).setColumns(tracks.length);
37 trackViews = new MooTrackView[tracks.length];
38 for (int i = 0; i < tracks.length; i++) {
39 trackViews[i] = new MooTrackView(tracks[i]);
40 trackPanel.add(new MooTrackView(tracks[i]));
42 trackPanel.validate();
45 public void update(Track[] tracks) {
51 * Creates a view for the given track and adds it to the main view.
52 * @param track the track for which to add a view
54 public void addTrackView(Track track) {
59 * Removes the view for the given track.
60 * @param track the track for which to remove the view
62 public void removeTrackView(Track track) {