|
@@ -42,6 +42,7 @@ public class StatisticGraphPanel extends JPanel {
|
|
|
private final JPanel legendPanel = new JPanel();
|
|
|
private JPanel that;
|
|
|
private Hashtable<String, StatisticGraphPanel> graphHashtable;
|
|
|
+ private JPanel tempP; // for makeLegend
|
|
|
|
|
|
/**
|
|
|
* Constructor.
|
|
@@ -136,21 +137,24 @@ public class StatisticGraphPanel extends JPanel {
|
|
|
* Make the LegendPane.
|
|
|
*/
|
|
|
public void makeLegendPanel() {
|
|
|
- for (TrackedDataSet set: sGraph.objects) {
|
|
|
+ legendPanel.removeAll();
|
|
|
+ for (TrackedDataSet set : sGraph.objects) {
|
|
|
JLabel b = new JLabel(set.getCpsObject().getName());
|
|
|
b.setBackground(Color.CYAN);
|
|
|
b.setOpaque(true);
|
|
|
- JPanel p = new JPanel();
|
|
|
- p.add(b);
|
|
|
+ tempP = new JPanel();
|
|
|
+ tempP.add(b);
|
|
|
b.addMouseListener(new MouseAdapter() {
|
|
|
@Override
|
|
|
public void mousePressed(MouseEvent e) {
|
|
|
- if (e.BUTTON3 == e.getButton())
|
|
|
- legendPanel.remove(p);
|
|
|
- that.updateUI();
|
|
|
+ if (e.BUTTON3 == e.getButton()) {
|
|
|
+ legendPanel.remove(tempP);
|
|
|
+ that.updateUI();
|
|
|
+ }
|
|
|
}
|
|
|
});
|
|
|
- legendPanel.add(p);
|
|
|
+ legendPanel.add(tempP);
|
|
|
}
|
|
|
+ updateUI();
|
|
|
}
|
|
|
}
|