1
2
3
4 package edu.jiangxin.apktoolbox.help;
5
6 import java.awt.*;
7 import java.io.BufferedReader;
8 import java.io.IOException;
9 import java.io.InputStream;
10 import java.io.InputStreamReader;
11
12 import javax.swing.BoxLayout;
13 import javax.swing.JEditorPane;
14 import javax.swing.JScrollPane;
15 import javax.swing.border.EmptyBorder;
16
17 import edu.jiangxin.apktoolbox.Version;
18 import edu.jiangxin.apktoolbox.swing.extend.EasyPanel;
19
20
21
22
23
24
25 public class AboutPanel extends EasyPanel {
26
27 private static final long serialVersionUID = 1L;
28
29 @Override
30 public void initUI() {
31 setBorder(new EmptyBorder(10, 10, 10, 10));
32 BoxLayout boxLayout = new BoxLayout(this, BoxLayout.Y_AXIS);
33 setLayout(boxLayout);
34
35 InputStream inputStream = null;
36 BufferedReader bufferedReader = null;
37 StringBuffer stringBuffer = new StringBuffer();
38 try {
39 inputStream = AboutPanel.class.getResourceAsStream("/about.html");
40 bufferedReader = new BufferedReader(new InputStreamReader(inputStream, "UTF-8"));
41 String line = "";
42 while ((line = bufferedReader.readLine()) != null) {
43 stringBuffer.append(line);
44 stringBuffer.append("\n");
45 }
46 } catch (IOException ex) {
47 logger.error("processing file failed", ex);
48 } finally {
49 try {
50 if (bufferedReader != null) {
51 bufferedReader.close();
52 }
53 } catch (Exception ex) {
54 logger.error("close bufferedReader failed", ex);
55 }
56
57 try {
58 if (inputStream != null) {
59 inputStream.close();
60 }
61 } catch (Exception ex) {
62 logger.error("close inputStream failed", ex);
63 }
64
65 }
66
67 JEditorPane editorPane = new JEditorPane("text/html",
68 stringBuffer.toString().replace("{VERSION}", Version.VERSION));
69 editorPane.setEditable(false);
70
71 JScrollPane scrollPane = new JScrollPane(editorPane);
72 scrollPane.setPreferredSize(new Dimension(800, 300));
73
74 add(scrollPane);
75 }
76
77 }