2 import java.awt.event.*;
6 * Graphical representation of a MIDI track.
8 * @author Andersson, Andreen, Lanneskog, Pehrson
12 public class MooTrackView extends JPanel implements ActionListener {
14 private MooTrackTitle title;
15 private NoteArea notes;
16 private Rectangle box;
17 <<<<<<< MooTrackView.java
18 private JPopupMenu popup;
19 private JMenuItem menuItem;
20 private String newline = "\n";
23 //private Rectangle box2;
24 //private JPanel notes;
26 private static final int PANEL_WIDTH = 65;
27 private static final int TITLE_HEIGHT = 45;
28 private static final int NOTEVIEW_HEIGHT = 200;
34 public MooTrackView () {
35 setLayout(new BorderLayout());
36 this.setBorder(BorderFactory.createLineBorder(Color.black));
37 add(trackTitle(), BorderLayout.NORTH);
38 add(noteView(), BorderLayout.CENTER);
41 private JPanel trackTitle () {
42 title = new MooTrackTitle();
43 title.setPreferredSize(new Dimension(PANEL_WIDTH, TITLE_HEIGHT));
44 title.setBorder(BorderFactory.createLineBorder(Color.black));
48 private JPanel noteView () {
49 notes = new NoteArea();
50 notes.setBackground(Color.white);
51 notes.setBorder(BorderFactory.createLineBorder(Color.black));
53 popup = new JPopupMenu();
54 menuItem = new JMenuItem("Add...");
55 menuItem.addActionListener(this);
57 menuItem = new JMenuItem("Preferences...");
58 menuItem.addActionListener(this);
61 MouseListener popupListener = new PopupListener();
62 notes.addMouseListener(popupListener);
67 public void actionPerformed(ActionEvent e) {
68 JMenuItem source = (JMenuItem)(e.getSource());
69 String s = "Action event detected."
71 + " Event source: " + source.getText();
74 class NoteArea extends JPanel {
75 public void RectanglePanel() {
76 setPreferredSize(new Dimension(20, 20));
80 public void paintComponent(Graphics g) {
81 super.paintComponent(g);
82 Graphics2D g2 = (Graphics2D)g;
83 for (int c=0;c<1000;c=c+20) {
85 for (r=0;r<200;r=r+20) {
86 box = new Rectangle(r,c,20,20);
87 g2.setColor(Color.gray);
93 <<<<<<< MooTrackView.java
95 class PopupListener extends MouseAdapter {
96 public void mousePressed(MouseEvent e) {
100 public void mouseReleased(MouseEvent e) {
104 private void maybeShowPopup(MouseEvent e) {
105 if (e.isPopupTrigger()) {
106 popup.show(e.getComponent(),
112 private static final int PANEL_WIDTH = 65;
113 private static final int TITLE_HEIGHT = 40;
114 private static final int NOTEVIEW_HEIGHT = 200;