OSDN Git Service

78617a5f2209c7c48a676a52a237a2135efbeb48
[importpicture/importpicture.git] / src / osm / jp / gpx / matchtime / gui / Card.java
1 package osm.jp.gpx.matchtime.gui;
2
3 import java.awt.BorderLayout;
4 import java.awt.event.ActionEvent;
5 import java.util.ResourceBundle;
6 import javax.swing.Box;
7 import javax.swing.JButton;
8 import javax.swing.JPanel;
9 import javax.swing.JTabbedPane;
10
11 /**
12  *
13  * @author yuu
14  */
15 public class Card extends JPanel {
16     public ResourceBundle i18n = ResourceBundle.getBundle("i18n");
17     JTabbedPane tabbe;
18     public JPanel mainPanel;
19     String title;
20     int backNumber = -1;
21     int nextNumber = -1;
22     JButton nextButton;     // [次へ]ボタン
23     JButton backButton;     // [戻る]ボタン
24     
25     public Card(JTabbedPane tabbe, String title, int backNumber, int nextNumber) {
26         super();
27         this.tabbe = tabbe;
28         this.title = title;
29         this.backNumber = backNumber;
30         this.nextNumber = nextNumber;
31
32         // INIT_CONTROLS
33         this.setLayout(new BorderLayout());
34         
35         //---- CENTER -----
36         mainPanel = new JPanel();
37         mainPanel.setLayout(new BorderLayout());
38         this.add(mainPanel, BorderLayout.CENTER);
39         
40         //---- SOUTH -----
41         JPanel buttonPanel = new JPanel(new BorderLayout());
42         buttonPanel.add(Box.createVerticalStrut(10), BorderLayout.SOUTH);
43         buttonPanel.add(Box.createVerticalStrut(10), BorderLayout.NORTH);
44         this.add(buttonPanel, BorderLayout.SOUTH);
45         
46         //{{REGISTER_LISTENERS
47         SymAction lSymAction = new SymAction();
48         if (nextNumber >= 0) {
49             nextButton = new JButton(i18n.getString("button.next"));
50             buttonPanel.add(nextButton, BorderLayout.EAST);
51             nextButton.addActionListener(lSymAction);
52         }
53
54         if (backNumber >= 0) {
55             backButton = new JButton(i18n.getString("button.previous"));
56             buttonPanel.add(backButton, BorderLayout.WEST);
57             backButton.addActionListener(lSymAction);
58         }
59         //}}
60     }
61     
62     public String getTitle() {
63         return this.title;
64     }
65     
66     /**
67      * [次へ]ボタンをクリックした時の動作
68      * @param event 
69      */
70     void nextButton_Action(ActionEvent event) {
71         this.tabbe.setSelectedIndex(this.nextNumber);
72     }
73
74     /**
75      * [戻る]ボタンをクリックした時の動作
76      * @param event
77      */
78     void backButton_Action(ActionEvent event) {
79         this.tabbe.setSelectedIndex(this.backNumber);
80     }
81
82     class SymAction implements java.awt.event.ActionListener {
83         @Override
84         public void actionPerformed(java.awt.event.ActionEvent event) {
85             Object object = event.getSource();
86             if (object == nextButton) {
87                 nextButton_Action(event);
88             }
89             else if (object == backButton) {
90                 backButton_Action(event);
91             }
92         }
93     }
94 }