OSDN Git Service

fixed: GUIを一新した
[importpicture/importpicture.git] / src / osm / jp / gpx / matchtime / gui / AboutDialog.java
1 package osm.jp.gpx.matchtime.gui;
2 import java.awt.*;
3
4 @SuppressWarnings("serial")
5 public class AboutDialog extends Dialog
6 {
7     //{{DECLARE_CONTROLS
8     java.awt.Label label1;
9     java.awt.Button okButton;
10     java.awt.Label label2;
11     //}}
12
13     // Used for addNotify redundency check.
14     boolean fComponentsAdjusted = false;
15
16     class SymWindow extends java.awt.event.WindowAdapter
17     {
18         @Override
19         public void windowClosing(java.awt.event.WindowEvent event) {
20             Object object = event.getSource();
21             if (object == AboutDialog.this) {
22                 AboutDialog_WindowClosing(event);
23             }
24         }
25     }
26
27     class SymAction implements java.awt.event.ActionListener
28     {
29         @Override
30         public void actionPerformed(java.awt.event.ActionEvent event) {
31             Object object = event.getSource();
32             if (object == okButton) {
33                 okButton_Clicked(event);
34             }
35         }
36     }
37
38     @SuppressWarnings("OverridableMethodCallInConstructor")
39     public AboutDialog(Frame parent, boolean modal) {
40         super(parent, modal);
41
42         // This code is automatically generated by Visual Cafe when you add
43         // components to the visual environment. It instantiates and initializes
44         // the components. To modify the code, only use code syntax that matches
45         // what Visual Cafe can generate, or Visual Cafe may be unable to back
46         // parse your Java file into its visual environment.
47
48
49         //{{INIT_CONTROLS
50         setLayout(null);
51         setVisible(false);
52         setSize(360,114);
53         label1 = new java.awt.Label(AdjustTime.PROGRAM_NAME +" Version "+ AdjustTime.PROGRAM_VARSION +" ("+ AdjustTime.PROGRAM_UPDATE +")", Label.CENTER);
54         label1.setBounds(10,10,340,20);
55         add(label1);
56         okButton = new java.awt.Button();
57         okButton.setLabel("OK");
58         okButton.setBounds(145,65,66,27);
59         add(okButton);
60         label2 = new java.awt.Label("Copyright(C) 2014,2018, yuuhayashi \n The MIT License (MIT).",Label.RIGHT);
61         label2.setBounds(10,40,340,20);
62         add(label2);
63         setTitle("About... "+ AdjustTime.PROGRAM_NAME);
64         //}}
65
66         //{{REGISTER_LISTENERS
67         SymWindow aSymWindow = new SymWindow();
68         this.addWindowListener(aSymWindow);
69         SymAction lSymAction = new SymAction();
70         okButton.addActionListener(lSymAction);
71         //}}
72     }
73
74     @SuppressWarnings("OverridableMethodCallInConstructor")
75     public AboutDialog(Frame parent, String title, boolean modal) {
76         this(parent, modal);
77         setTitle(title);
78     }
79
80     @Override
81     public void addNotify() {
82         // Record the size of the window prior to calling parents addNotify.
83
84         super.addNotify();
85
86         // Only do this once.
87         if (fComponentsAdjusted) {
88             return;
89         }
90
91         // Adjust components according to the insets
92         setSize(getInsets().left + getInsets().right + getSize().width, getInsets().top + getInsets().bottom + getSize().height);
93         Component components[] = getComponents();
94         for (Component component : components) {
95             Point p = component.getLocation();
96             p.translate(getInsets().left, getInsets().top);
97             component.setLocation(p);
98         }
99
100         // Used for addNotify check.
101         fComponentsAdjusted = true;
102     }
103
104     /**
105     * Shows or hides the component depending on the boolean flag b.
106     * @param b  if true, show the component; otherwise, hide the component.
107     * @see java.awt.Component#isVisible
108     */
109     @Override
110     public void setVisible(boolean b) {
111         if(b) {
112             Rectangle bounds = getParent().getBounds();
113             Rectangle abounds = getBounds();
114             setLocation(bounds.x + (bounds.width - abounds.width)/ 2,
115             bounds.y + (bounds.height - abounds.height)/2);
116         }
117         super.setVisible(b);
118     }
119
120     void AboutDialog_WindowClosing(java.awt.event.WindowEvent event) {
121         dispose();
122     }
123
124     void okButton_Clicked(java.awt.event.ActionEvent event) {
125         //{{CONNECTION
126         // Clicked from okButton Hide the Dialog
127         dispose();
128         //}}
129     }
130 }