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 JPanel trackPanel;
17 * Creates the main view
19 public MooView(Track[] tracks) {
20 super(VERTICAL_SCROLLBAR_ALWAYS, HORIZONTAL_SCROLLBAR_AS_NEEDED);
21 trackPanel = new JPanel(new GridLayout(1,3), true);
23 setViewportView(trackPanel);
27 * Fills the track panel with track views for all tracks in the current sequence.
28 * @param tracks the tracks for which to add views
30 public void setTracks(Track[] tracks) {
31 trackPanel.removeAll();
32 ((GridLayout)trackPanel.getLayout()).setColumns(tracks.length);
33 for (int i = 0; i < tracks.length; i++) {
34 trackPanel.add(new MooTrackView(tracks[i]));
36 trackPanel.validate();
41 * Calls on each track view to update itself.
43 public void update() {
44 Component[] comps = getComponents();
45 for (int i = 0; i < comps.length; i++) {
46 ((MooTrackView)comps[i]).update();
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
53 * @param index the index at which to insert the view
55 public void addTrackView(Track track, int index) {
56 add(new MooTrackView(track), index);
61 * Removes the view for the given track.
62 * @param index the index of the track for which to remove the view
64 public void removeTrackView(int index) {