wangting
2024-12-26 fa261e8c1220b31af54e8167e4de9c3320b1af27
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
package com.vci.client.logon.base;
 
import java.awt.Color;
import java.awt.Cursor;
import java.awt.Frame;
import java.awt.Rectangle;
import java.awt.Toolkit;
import java.awt.Window;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
 
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JTextArea;
 
import com.vci.client.common.ConfigUtils;
import com.vci.client.ui.image.BundleImage;
 
/**
 * 关于窗口
 */
public class AboutDialog extends JDialog {
    
    /**
     * 所属窗口
     */
    private Frame owner;
    /**
     * 图片标签
     */
    private JLabel imageLabel;
    /**
     * 文本标签
     */
    private JTextArea txtArea;
    /**
     * 访问链接
     */
    private JLabel visitLabel;
    /**
     * 关闭按钮
     */
    private JButton ok_btn;
    /**
     * 图片名称
     */
    private String imageName = "about.png";
    /**
     * 标题
     */
    private String title = "关于";
    /**
     * 软件名称
     */
    private String softName = "Innovation 开发平台";
    /**
     * 版本
     */
    private String version = "8.0.7600.16385";
    /**
     * 网址
     */
    private String visit = "http://www.vci-tech.com";
    
    /**
     * 产品
     */
    
    private String softNameProduct = "宏博远达  Innovation 2023";
    
    /**
     * 版权_中文
     */
    private String softNameCopyrightC = "北京宏博远达科技有限公司  ©版权所有";
    /**
     * 版权_英文
     */
    private String softNameCopyrightE = "VCI Copyright(C) 2011-2023 Contributors. All rights reserved.";
    
    
    /**
     * 
     */
    
    /**
     * 构造器
     */
    public AboutDialog(Frame owner, boolean modal){
        super(owner, modal);
        this.owner = owner;
 
        try {
            //获得配置信息
            String conTitle = ConfigUtils.getConfigValue("system.about.title");
            if(conTitle != null && !conTitle.equals("")){
                conTitle = new String(conTitle.getBytes("iso-8859-1"),"utf-8");
                title = conTitle;
            }
            String conImageName = ConfigUtils.getConfigValue("system.about.imageName");
            if(conImageName != null && !conImageName.equals("")){
                conImageName = new String(conImageName.getBytes("iso-8859-1"),"utf-8");
                imageName = conImageName;
            }
            String conSoftName = ConfigUtils.getConfigValue("system.about.softName");
            if(conSoftName != null && !conSoftName.equals("")){
                conSoftName = new String(conSoftName.getBytes("iso-8859-1"),"utf-8");
                softName = conSoftName;
            }
            String conVersion = ConfigUtils.getConfigValue("system.about.version");
            if(conVersion != null && !conVersion.equals("")){
                conVersion = new String(conVersion.getBytes("iso-8859-1"),"utf-8");
                version = conVersion;
            }
            String conVisit = ConfigUtils.getConfigValue("system.about.visit");
            if(conVisit != null && !conVisit.equals("")){
                conVisit = new String(conVisit.getBytes("iso-8859-1"),"utf-8");
                visit = conVisit;
            }
            
            String conSoftNameProduct = ConfigUtils.getConfigValue("system.about.softNameProduct");
            if(conSoftNameProduct != null && !conSoftNameProduct.equals("")){
                conSoftNameProduct = new String(conSoftNameProduct.getBytes("iso-8859-1"),"utf-8");
                softNameProduct = conSoftNameProduct;
            }
            
            String conSoftNameCopyrightC = ConfigUtils.getConfigValue("system.about.softNameCopyrightC");
            if(conSoftNameCopyrightC != null && !conSoftNameCopyrightC.equals("")){
                conSoftNameCopyrightC = new String(conSoftNameCopyrightC.getBytes("iso-8859-1"),"utf-8");
                softNameCopyrightC = conSoftNameCopyrightC;
            }
            
            String conSoftNameCopyrightE = ConfigUtils.getConfigValue("system.about.softNameCopyrightE");
            if(conSoftNameCopyrightE != null && !conSoftNameCopyrightE.equals("")){
                conSoftNameCopyrightE = new String(conSoftNameCopyrightE.getBytes("iso-8859-1"),"utf-8");
                softNameCopyrightE = conSoftNameCopyrightE;
            }
            
        } catch (UnsupportedEncodingException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        this.setTitle(title);
        init();
    }
    
    /**
     * 绘制窗口
     */
    private void init(){
        Color bg = this.getContentPane().getBackground();
        setLayout(null);
        setSize(400, 300);
        imageLabel = new JLabel();
        BundleImage bi = new BundleImage();
        bi.setPath("/resource/icons/");
        imageLabel.setIcon(bi.createImageIcon(imageName));
        imageLabel.setBounds(new Rectangle(0, 0, 400, 90));
        txtArea =  new JTextArea();
        txtArea.setBackground(bg);
        StringBuffer sb = new StringBuffer();
        sb.append(softName).append("\n")
          .append("\n")
          .append("产品:").append(softNameProduct).append("\n")
          .append("版本:").append(version).append("\n")
          .append("版权:").append(softNameCopyrightC).append("\n")
          .append("      ").append(softNameCopyrightE).append("\n");
        txtArea.setText(sb.toString());
        txtArea.setEditable(false);
        txtArea.setBounds(new Rectangle(10, 95, 370, 105));
        visitLabel = new JLabel("<html><body><a href='" + visit + "'>" + visit + "</a></body></html>");
        visitLabel.setBounds(new Rectangle(15, 200, 150, 25));
        visitLabel.addMouseListener(new MouseAdapter() {
            public void mouseExited(MouseEvent e) {
                visitLabel.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
            }
            public void mouseEntered(MouseEvent e) {
                visitLabel.setCursor(new Cursor(Cursor.HAND_CURSOR));
            }
            public void mouseClicked(MouseEvent e) {
                try {
                    Runtime.getRuntime().exec("cmd.exe /c start " + visit);
                } catch (IOException e1) {
                    e1.printStackTrace();
                }
            }
        });
        ok_btn = new JButton("确定");
        ok_btn.setBounds(new Rectangle(280, 230, 75, 25));
        ok_btn.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                okBtn();
            }
        });
        this.getContentPane().add(imageLabel);
        this.getContentPane().add(txtArea);
        this.getContentPane().add(visitLabel);
        this.getContentPane().add(ok_btn);
        setResizable(false);
        setWindowLocation(this);
        validate();
        setVisible(true);
    }
 
    /**
     * 关闭事件
     */
    private void okBtn(){
        this.dispose();
    }
    
    /**
     * 设置窗体居中
     * @param window
     */
    private void setWindowLocation(Window window){
        //屏幕大小
        int width = Toolkit.getDefaultToolkit().getScreenSize().width; 
        int height = Toolkit.getDefaultToolkit().getScreenSize().height - 20;
        //窗口大小
        int windowWidth = window.getSize().width;
        int windowHeight = window.getSize().height;
        //窗口定点位置
        int left = (width - windowWidth) / 2;
        int top = (height - windowHeight) / 2;
        
        window.setBounds(left, top, windowWidth, windowHeight);
    }
    
    public static void main(String[] args){
        Frame f = new JFrame();
        f.setSize(200, 300);
        new AboutDialog(f, true);
    }
}