import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
+import javax.sound.midi.*;
/**
* The title bar for each track with track name, channel, instrument etc.
* @version 1
*/
-public class MooTrackTitle extends JPanel{
+public class MooTrackTitle extends JPanel {
+ private JTextField title;
private MooInstrumentList instruments;
private JComboBox channel;
private JCheckBox mute;
private JCheckBox solo;
+ private Track track;
/**
* Creates the title bar.
*/
- public MooTrackTitle () {
- setLayout(new GridLayout(3,1));
+ public MooTrackTitle (Track aTrack) {
+ track = aTrack;
+ setLayout(new GridLayout(4,1));
+ setBorder(BorderFactory.createLineBorder(Color.black));
+
+ setPreferredSize(new Dimension(MooTrackView.VIEW_WIDTH,70));
+ title = new JTextField(); // JTextField(String text, int columns)
+ title.setFont(Moosique.getGUI().FONT);
+ title.addFocusListener(new TitleFocusListener());
+ add(title);
+
instruments = new MooInstrumentList();
add(instruments);
checkboxes.setLayout(new GridLayout(1,3));
channel = new JComboBox();
- channel.setFont(new Font("Helvetica", Font.PLAIN, 10));
+ channel.setFont(Moosique.getGUI().FONT);
for (int i = 1; i <= 16; i++)
channel.addItem(new Integer(i));
+
+ for (int j = 0; j < track.size(); j++) {
+ MidiEvent me = track.get(j);
+ if (me instanceof MooNote){
+ MooNote mn = (MooNote)me;
+ channel.setSelectedIndex(mn.getChannel());
+ break;
+ }
+ }
+
channel.addItemListener(new ItemListener(){
public void itemStateChanged(ItemEvent e){
Object ob = channel.getSelectedItem();
if (ob instanceof Integer){
+ int chan = ((Integer)ob).intValue();
//set channel
+ MidiEvent me;
+ MooNote mn;
+ for (int j = 0; j < track.size(); j++) {
+ me = track.get(j);
+ if (me instanceof MooNote){
+ mn = (MooNote)me;
+ mn.setChannel(chan);
+ System.out.println(ob);
+ }
+ }
}
}});
+
add(channel);
mute = new JCheckBox("Mute");
- mute.setFont(new Font("Helvetica", Font.PLAIN, 10));
+ mute.setFont(Moosique.getGUI().FONT);
mute.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent event){
//setMute
checkboxes.add(mute);
solo = new JCheckBox("Solo");
- solo.setFont(new Font("Helvetica", Font.PLAIN, 10));
+ solo.setFont(Moosique.getGUI().FONT);
solo.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent event){
//setSolo
checkboxes.add(solo);
add(checkboxes);
}
+
+ class TitleFocusListener extends FocusAdapter {
+ public void focusLost(FocusEvent e) {
+ // Update the MidiEvent containing the title of this track
+ }
+ }
}