1 | package weka.clusterers.forMetisMQI.util; |
---|
2 | |
---|
3 | import java.awt.CardLayout; |
---|
4 | import java.awt.Rectangle; |
---|
5 | import java.awt.event.ActionEvent; |
---|
6 | import java.awt.event.ActionListener; |
---|
7 | |
---|
8 | import javax.swing.JButton; |
---|
9 | import javax.swing.JFrame; |
---|
10 | import javax.swing.JPanel; |
---|
11 | |
---|
12 | public class GraphsFrame extends JFrame { |
---|
13 | |
---|
14 | /** |
---|
15 | * |
---|
16 | */ |
---|
17 | private static final long serialVersionUID = 1L; |
---|
18 | |
---|
19 | private int numberOfPanels = 0; |
---|
20 | |
---|
21 | private JPanel graphPanel = null; |
---|
22 | private JPanel buttonPanel = null; |
---|
23 | private JButton nextButton = null; |
---|
24 | private JButton prevButton = null; |
---|
25 | |
---|
26 | public GraphsFrame(String name) { |
---|
27 | super(name); |
---|
28 | setBounds(new Rectangle(800, 700)); |
---|
29 | |
---|
30 | graphPanel = new JPanel(); |
---|
31 | graphPanel.setName("graphPanel"); |
---|
32 | graphPanel.setBounds(0,40,800, 660); |
---|
33 | graphPanel.setLayout(new CardLayout()); |
---|
34 | getContentPane().add(graphPanel); |
---|
35 | |
---|
36 | buttonPanel = new JPanel(); |
---|
37 | nextButton = new JButton(">>"); |
---|
38 | |
---|
39 | nextButton.addActionListener(new ActionListener() { |
---|
40 | @Override |
---|
41 | public void actionPerformed(ActionEvent e) { |
---|
42 | CardLayout c = (CardLayout) graphPanel.getLayout(); |
---|
43 | c.next(graphPanel); |
---|
44 | } |
---|
45 | }); |
---|
46 | prevButton = new JButton("<<"); |
---|
47 | prevButton.addActionListener(new ActionListener() { |
---|
48 | @Override |
---|
49 | public void actionPerformed(ActionEvent e) { |
---|
50 | CardLayout c = (CardLayout) graphPanel.getLayout(); |
---|
51 | c.previous(graphPanel); |
---|
52 | } |
---|
53 | }); |
---|
54 | buttonPanel.setBounds(0, 0, 800, 40); |
---|
55 | buttonPanel.add(prevButton); |
---|
56 | buttonPanel.add(nextButton); |
---|
57 | getContentPane().add(buttonPanel); |
---|
58 | } |
---|
59 | |
---|
60 | public void addPanel(JPanel panel) { |
---|
61 | graphPanel.add(panel, Integer.toString(numberOfPanels)); |
---|
62 | numberOfPanels++; |
---|
63 | } |
---|
64 | } |
---|