/
BoxInfo.java
185 lines (171 loc) · 5.46 KB
/
BoxInfo.java
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
package de.FBEditor;
import java.awt.Dimension;
import java.awt.GridLayout;
import java.io.IOException;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.Socket;
import java.net.SocketAddress;
import java.net.UnknownHostException;
import java.util.regex.Pattern;
import javax.swing.JButton;
import javax.swing.JEditorPane;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JDialog;
import java.awt.GridBagLayout;
import javax.swing.JScrollPane;
import java.awt.GridBagConstraints;
import de.moonflower.jfritz.exceptions.WrongPasswordException;
public class BoxInfo extends JDialog {
private static final long serialVersionUID = 1L;
private JPanel jPanel = null;
private JButton jButton = null;
private JScrollPane jScrollPane = null;
private JEditorPane fbeditorPane = null;
private JPanel jPanel1 = null;
private JLabel jLabel2;
private JLabel jLabel4;
private JLabel jLabel6;
/**
* This is the default constructor
* @throws InvalidFirmwareException
* @throws IOException
* @throws WrongPasswordException
*/
public BoxInfo(String boxName, String firmwareVersion, String modVersion) {
super();
this.setSize(500, 300);
this.setTitle(FBEdit.getMessage("menu.boxinfo"));
this.setIconImage(FBEdit.getInstance().getImageFromJAR("/icon.gif"));
this.setContentPane(getJPanel());
this.setLocationRelativeTo(FBEdit.getInstance().getframe());
this.setVisible(true);
setPanelText(boxName, firmwareVersion, modVersion);
}
/**
* This method initializes jPanel
*
* @return javax.swing.JPanel
*/
private JPanel getJPanel() {
if (jPanel == null) {
GridBagConstraints gridBagConstraints2 = new GridBagConstraints();
// gridBagConstraints2.insets = new java.awt.Insets(53,3,112,74);
gridBagConstraints2.gridy = 1;
gridBagConstraints2.gridx = 0;
gridBagConstraints2.weightx = 1.0;
gridBagConstraints2.weighty = 0.25;
gridBagConstraints2.fill = 1;
GridBagConstraints gridBagConstraints1 = new GridBagConstraints();
gridBagConstraints1.fill = java.awt.GridBagConstraints.BOTH;
gridBagConstraints1.gridx = 0;
gridBagConstraints1.gridy = 0;
// gridBagConstraints1.weightx = 1.0;
gridBagConstraints1.weighty = 0.65;
gridBagConstraints1.fill = 1;
// gridBagConstraints1.insets = new java.awt.Insets(5,3,64,2);
GridBagConstraints gridBagConstraints = new GridBagConstraints();
// gridBagConstraints.insets = new java.awt.Insets(100,74,159,2);
gridBagConstraints.gridy = 2;
gridBagConstraints.gridx = 0;
// gridBagConstraints.weightx = 1.0;
gridBagConstraints.weighty = 0.1;
jPanel = new JPanel();
jPanel.setLayout(new GridBagLayout());
jPanel.setComponentOrientation(java.awt.ComponentOrientation.LEFT_TO_RIGHT);
jPanel.add(getJButton(), gridBagConstraints);
jPanel.add(getJScrollPane(), gridBagConstraints1);
jPanel.add(getJPanel1(), gridBagConstraints2);
}
return jPanel;
}
/**
* This method initializes jButton
*
* @return javax.swing.JButton
*/
private JButton getJButton() {
if (jButton == null) {
jButton = new JButton();
jButton.setPreferredSize(new java.awt.Dimension(115, 35));
jButton.setText(FBEdit.getMessage("menu.close"));
jButton.setToolTipText(FBEdit.getMessage("window.close"));
jButton.setName("close");
jButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent e) {
setVisible(false);
}
});
}
return jButton;
}
/**
* This method initializes jScrollPane
*
* @return javax.swing.JScrollPane
*/
private JScrollPane getJScrollPane() {
if (jScrollPane == null) {
jScrollPane = new JScrollPane();
jScrollPane.setPreferredSize(new java.awt.Dimension(200, 200));
jScrollPane.setViewportView(getJEditorPane());
}
return jScrollPane;
}
/**
* This method initializes fbeditorPane
*
* @return javax.swing.fbeditorPane
*/
private JEditorPane getJEditorPane() {
if (fbeditorPane == null) {
try {
String url = (new StringBuilder("http://")).append(FBEdit.getInstance().getbox_address()).append("/cgi-bin/system_status").toString();
fbeditorPane = new JEditorPane(url);
} catch (IOException e) {
e.printStackTrace();
}
}
return fbeditorPane;
}
/**
* This method initializes jPanel1
*
* @return javax.swing.JPanel
*/
private JPanel getJPanel1() {
if (jPanel1 == null) {
jPanel1 = new JPanel();
jPanel1.setLayout(new GridLayout(4, 2));
JLabel jLabel = new JLabel(FBEdit.getMessage("boxinfo.hardware"));
jLabel.setPreferredSize(new Dimension(100, 26));
jPanel1.add(jLabel);
jLabel2 = new JLabel();
jLabel2.setPreferredSize(new Dimension(100, 26));
jPanel1.add(jLabel2);
jLabel = new JLabel(FBEdit.getMessage("boxinfo.firmware"));
jLabel.setPreferredSize(new Dimension(100, 26));
jPanel1.add(jLabel);
jLabel4 = new JLabel();
jLabel4.setPreferredSize(new Dimension(100, 26));
jPanel1.add(jLabel4);
jLabel = new JLabel(FBEdit.getMessage("boxinfo.modversion"));
jLabel.setPreferredSize(new Dimension(100, 26));
jPanel1.add(jLabel);
jLabel6 = new JLabel();
jLabel6.setPreferredSize(new Dimension(100, 26));
jPanel1.add(jLabel6);
}
return jPanel1;
}
public void setPanelText(String boxName, String firmwareVersion, String modVersion) {
jLabel2.setText(boxName);
jLabel4.setText(firmwareVersion);
if (modVersion.equals(""))
jLabel6.setText(FBEdit.getMessage("boxinfo.nomod"));
else
jLabel6.setText(modVersion);
}
}