3 import java.awt.event.*;
4 import javax.sound.midi.*;
7 * The title bar for each track with track name, channel, instrument etc.
9 * @author Andersson, Andreen, Lanneskog, Pehrson
13 public class MooTrackTitle extends JPanel {
15 private JTextField title;
16 private MooInstrumentList instruments;
17 private JComboBox channel;
18 private JCheckBox mute;
19 private JCheckBox solo;
22 * Creates the title bar.
24 public MooTrackTitle (Track aTrack) {
26 setLayout(new GridLayout(4,1));
27 setBorder(BorderFactory.createLineBorder(Color.black));
29 setPreferredSize(new Dimension(MooTrackView.VIEW_WIDTH,70));
30 title = new JTextField(); // JTextField(String text, int columns)
31 title.setFont(Moosique.getGUI().FONT);
32 title.addFocusListener(new TitleFocusListener());
36 JPanel checkboxes = new JPanel();
37 checkboxes.setLayout(new GridLayout(1,3));
39 channel = new JComboBox();
40 channel.setFont(Moosique.getGUI().FONT);
41 for (int i = 1; i <= 16; i++)
42 channel.addItem(new Integer(i));
44 for (int j = 0; j < track.size(); j++) {
45 MidiEvent me = track.get(j);
46 if (me instanceof MooNote){
47 MooNote mn = (MooNote)me;
48 channel.setSelectedIndex(mn.getChannel());
53 instruments = new MooInstrumentList(channel.getSelectedIndex());
55 channel.addActionListener(new ActionListener(){
56 public void actionPerformed(ActionEvent e){
57 int chan = channel.getSelectedIndex();
60 instruments.setChannel(channel.getSelectedIndex());
61 for (int j = 0; j < track.size(); j++) {
63 if (me instanceof MooNote){
72 mute = new JCheckBox("Mute");
73 mute.setFont(Moosique.getGUI().FONT);
74 mute.addActionListener(new ActionListener(){
75 public void actionPerformed(ActionEvent event){
77 solo.setSelected(false);
81 solo = new JCheckBox("Solo");
82 solo.setFont(Moosique.getGUI().FONT);
83 solo.addActionListener(new ActionListener(){
84 public void actionPerformed(ActionEvent event){
86 mute.setSelected(false);
95 class TitleFocusListener extends FocusAdapter {
96 public void focusLost(FocusEvent e) {
97 // Update the MidiEvent containing the title of this track