+ public MooTrackTitle (Track aTrack) {
+ setDoubleBuffered(true);
+ track = aTrack;
+
+ // Finds track name, program change and channel.
+ MidiMessage msg;
+ int status;
+ for (int i = 0; i < track.size(); i++) {
+ msg = track.get(i).getMessage();
+ status = msg.getStatus();
+ if (status == MetaMessage.META) {
+ if (((MetaMessage)msg).getType() == 3) {
+ trackNameMessage = (MetaMessage)msg;
+ trackName = new String(trackNameMessage.getData());
+ }
+ } else if (status >= 192 && status <= 207) {
+ programChangeMessage = (ShortMessage)msg;
+ channel = status - 192;
+ }
+ }
+
+ // Creates and places components.
+ setLayout(new GridLayout(4,1));
+ setBorder(BorderFactory.createLineBorder(Color.black));
+
+ setPreferredSize(new Dimension(MooTrackView.VIEW_WIDTH,70));
+ title = new JTextField(trackName);
+ title.setFont(Moosique.getGUI().FONT);
+ title.addFocusListener(new TitleFocusListener());
+ add(title);
+
+ int type;
+ if (channel == 9) type = MooInstrumentList.DRUMS;
+ else type = MooInstrumentList.INSTRUMENTS;
+ instruments = new MooInstrumentList(channel, type);
+ // instruments = new MooInstrumentList(channel, type, programChangeMessage);
+ add(instruments);
+
+ channelBox = new JComboBox();
+ channelBox.setFont(Moosique.getGUI().FONT);
+ for (int i = 1; i <= 16; i++)
+ channelBox.addItem(new Integer(i));
+
+ channelBox.setSelectedIndex(channel);
+
+ channelBox.addActionListener(new ActionListener(){
+ public void actionPerformed(ActionEvent e){
+ int chan = channelBox.getSelectedIndex();
+ MidiEvent me;
+ MooNote mn;
+ instruments.setChannel(channelBox.getSelectedIndex());
+ for (int j = 0; j < track.size(); j++) {
+ me = track.get(j);
+ if (me instanceof MooNote){
+ mn = (MooNote)me;
+ mn.setChannel(chan);
+ }
+ }}});
+ add(channelBox);