OSDN Git Service

AdjustTime
[importpicture/importpicture.git] / src / main / java / 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     public AboutDialog(Frame parent, boolean modal) {
39         super(parent, modal);
40
41         // This code is automatically generated by Visual Cafe when you add
42         // components to the visual environment. It instantiates and initializes
43         // the components. To modify the code, only use code syntax that matches
44         // what Visual Cafe can generate, or Visual Cafe may be unable to back
45         // parse your Java file into its visual environment.
46
47
48         //{{INIT_CONTROLS
49         setLayout(null);
50         setVisible(false);
51         setSize(360,114);
52         label1 = new java.awt.Label(AdjustTerra.PROGRAM_NAME +" Version "+ AdjustTerra.PROGRAM_VARSION +" ("+ AdjustTerra.PROGRAM_UPDATE +")", Label.CENTER);
53         label1.setBounds(10,10,340,20);
54         add(label1);
55         okButton = new java.awt.Button();
56         okButton.setLabel("OK");
57         okButton.setBounds(145,65,66,27);
58         add(okButton);
59         label2 = new java.awt.Label("Copyright(C) 2014,2018,2020 yuuhayashi \n The MIT License (MIT).",Label.RIGHT);
60         label2.setBounds(10,40,340,20);
61         add(label2);
62         setTitle("About... "+ AdjustTerra.PROGRAM_NAME);
63         //}}
64
65         //{{REGISTER_LISTENERS
66         SymWindow aSymWindow = new SymWindow();
67         this.addWindowListener(aSymWindow);
68         SymAction lSymAction = new SymAction();
69         okButton.addActionListener(lSymAction);
70         //}}
71     }
72
73     public AboutDialog(Frame parent, String title, boolean modal) {
74         this(parent, modal);
75         setTitle(title);
76     }
77
78     @Override
79     public void addNotify() {
80         // Record the size of the window prior to calling parents addNotify.
81
82         super.addNotify();
83
84         // Only do this once.
85         if (fComponentsAdjusted) {
86             return;
87         }
88
89         // Adjust components according to the insets
90         setSize(getInsets().left + getInsets().right + getSize().width, getInsets().top + getInsets().bottom + getSize().height);
91         Component components[] = getComponents();
92         for (Component component : components) {
93             Point p = component.getLocation();
94             p.translate(getInsets().left, getInsets().top);
95             component.setLocation(p);
96         }
97
98         // Used for addNotify check.
99         fComponentsAdjusted = true;
100     }
101
102     /**
103     * Shows or hides the component depending on the boolean flag b.
104     * @param b  if true, show the component; otherwise, hide the component.
105     * @see java.awt.Component#isVisible
106     */
107     @Override
108     public void setVisible(boolean b) {
109         if(b) {
110             Rectangle bounds = getParent().getBounds();
111             Rectangle abounds = getBounds();
112             setLocation(bounds.x + (bounds.width - abounds.width)/ 2,
113             bounds.y + (bounds.height - abounds.height)/2);
114         }
115         super.setVisible(b);
116     }
117
118     void AboutDialog_WindowClosing(java.awt.event.WindowEvent event) {
119         dispose();
120     }
121
122     void okButton_Clicked(java.awt.event.ActionEvent event) {
123         //{{CONNECTION
124         // Clicked from okButton Hide the Dialog
125         dispose();
126         //}}
127     }
128 }