|
@@ -12,6 +12,9 @@ import javax.swing.SwingConstants;
|
|
|
import java.awt.BorderLayout;
|
|
|
import javax.swing.border.LineBorder;
|
|
|
import java.awt.Color;
|
|
|
+import java.awt.Dimension;
|
|
|
+import java.awt.event.ActionEvent;
|
|
|
+import java.awt.event.ActionListener;
|
|
|
|
|
|
public class StatisticGraphPanel extends JPanel {
|
|
|
|
|
@@ -49,20 +52,37 @@ public class StatisticGraphPanel extends JPanel {
|
|
|
this.graphName = name;
|
|
|
setLayout(new BorderLayout(0, 0));
|
|
|
|
|
|
- //********** add everything **********//
|
|
|
- // Statistic Graph
|
|
|
- this.add(sGraph);
|
|
|
- // Graph Name and Close Button
|
|
|
+ // ******************** Component Propertys ***************//
|
|
|
+ //Graph Name
|
|
|
graphNameLabel = new JLabel(graphName);
|
|
|
- topPanel.add(graphNameLabel);
|
|
|
- topPanel.add(closeButton);
|
|
|
+ graphNameLabel.setHorizontalTextPosition(JLabel.CENTER);
|
|
|
+
|
|
|
+ //Panel on top (Name and Close Button)
|
|
|
+ topPanel.setLayout(new BorderLayout(0, 0));
|
|
|
+ topPanel.add(graphNameLabel, BorderLayout.CENTER);
|
|
|
+ topPanel.add(closeButton, BorderLayout.EAST);
|
|
|
topPanel.setBorder(null);
|
|
|
- this.add(topPanel, BorderLayout.NORTH);
|
|
|
- // Y Maximum
|
|
|
+
|
|
|
+ //Maximum Label
|
|
|
maximumLabel.setVerticalAlignment(SwingConstants.TOP);
|
|
|
+ maximumLabel.setPreferredSize(new Dimension(30,10));
|
|
|
+ // ******************** Component Listener ****************//
|
|
|
+
|
|
|
+ JPanel that = this;
|
|
|
+ closeButton.addActionListener(new ActionListener() {
|
|
|
+ @Override
|
|
|
+ public void actionPerformed(ActionEvent e) {
|
|
|
+ JPanel parent = (JPanel) that.getParent();
|
|
|
+ parent.remove(that);
|
|
|
+ parent.revalidate();
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ // ******************** add everything ********************//
|
|
|
+ this.add(sGraph);
|
|
|
+ this.add(topPanel, BorderLayout.NORTH);
|
|
|
this.add(maximumLabel, BorderLayout.WEST);
|
|
|
- // Legend Panel
|
|
|
- add(Legendpanel, BorderLayout.SOUTH);
|
|
|
+ this.add(Legendpanel, BorderLayout.SOUTH);
|
|
|
}
|
|
|
|
|
|
/**
|