2 import java.awt.event.MouseListener;
3 import java.awt.event.MouseEvent;
4 import java.awt.event.MouseMotionAdapter;
5 import java.awt.event.MouseMotionListener;
6 import java.awt.Dimension;
8 //import java.awt.Graphics;
9 //import java.awt.Graphics2D;
10 //import java.awt.Rectangle;
15 * @author Andersson, Andreen, Lanneskog, Pehrson
19 public class MooTrackView extends JPanel{
21 private MooTrackTitle title;
22 private JScrollPane table;
27 public MooTrackView () {
28 this.addMouseMotionListener(doScrollRectToVisible);
29 setLayout(new BorderLayout());
30 this.setBorder(BorderFactory.createLineBorder(Color.black));
31 add(trackTitle(), BorderLayout.NORTH);
32 add(noteView(), BorderLayout.SOUTH);
35 MouseMotionListener doScrollRectToVisible = new MouseMotionAdapter() {
36 public void mouseDragged(MouseEvent e) {
37 Rectangle r = new Rectangle(e.getX(), e.getY(), 1, 1);
38 ((JPanel)e.getSource()).scrollRectToVisible(r);
42 private JPanel trackTitle () {
43 title = new MooTrackTitle();
44 title.setPreferredSize(new Dimension(PANEL_WIDTH, TITLE_HEIGHT));
45 title.setBorder(BorderFactory.createLineBorder(Color.black));
49 private JScrollPane noteView() {
50 JScrollPane scrollPane = new JScrollPane(table);
51 table.setPreferredScrollableViewportSize(new Dimension(500, 70));
57 private static final int PANEL_WIDTH = 65;
58 private static final int TITLE_HEIGHT = 20;
59 private static final int NOTEVIEW_HEIGHT = 200;
60 private static final int BOX_WIDTH = 20;
61 private static final int BOX_HEIGHT = 20;