-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHelp.java
115 lines (96 loc) · 3.22 KB
/
Help.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
/*
Copyright (C) 2010 Petri Tuononen
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gui;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.IOException;
import java.net.URL;
import javax.swing.*;
/**
* Help window. Contents are loaded from a html file.
*
* @author Petri Tuononen
* @since 11/03/2010
*/
public class Help extends JFrame {
private static final long serialVersionUID = -7279256753979554192L;
/**
* Constructor.
*/
public Help() {
initComponents();
}
//Variables declaration
private JScrollPane scrollPane1;
private JEditorPane editorPane1;
private JButton button1;
ClassLoader cl = Thread.currentThread().getContextClassLoader();
URL urlHelp = cl.getResource("Help.html");
/**
* Initialises graphical user interface components.
*/
private void initComponents() {
if (urlHelp==null) {
System.out.println("NULL");
}
scrollPane1 = new JScrollPane();
editorPane1 = new JEditorPane();
button1 = new JButton();
//======== container ========
setVisible(true);
setTitle("Help - Petri's Chess");
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
Container contentPane = getContentPane();
contentPane.setLayout(new GridBagLayout());
((GridBagLayout)contentPane.getLayout()).columnWidths = new int[] {10, 0, 65, 5, 0};
((GridBagLayout)contentPane.getLayout()).rowHeights = new int[] {10, 0, 30, 5, 0};
((GridBagLayout)contentPane.getLayout()).columnWeights = new double[] {0.0, 1.0, 0.0, 0.0, 1.0E-4};
((GridBagLayout)contentPane.getLayout()).rowWeights = new double[] {0.0, 1.0, 0.0, 0.0, 1.0E-4};
//======== scrollPane1 ========
{
//---- editorPane1 ----
editorPane1.setEditable(false);
editorPane1.setContentType("text/html");
scrollPane1.setViewportView(editorPane1);
try {
editorPane1.setPage(urlHelp);
} catch (IOException e) {
editorPane1.setText("Help file not found");
}
}
contentPane.add(scrollPane1, new GridBagConstraints(1, 1, 2, 1, 0.0, 0.0,
GridBagConstraints.CENTER, GridBagConstraints.BOTH,
new Insets(0, 0, 5, 5), 0, 0));
//---- button1 ----
button1.setText("Close");
button1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
closeButtonActionPerformed(e);
}
});
contentPane.add(button1, new GridBagConstraints(2, 2, 1, 1, 0.0, 0.0,
GridBagConstraints.CENTER, GridBagConstraints.BOTH,
new Insets(0, 0, 5, 5), 0, 0));
setSize(900, 650);
setLocationRelativeTo(null);
}
/**
* Closes frame.
* @param e
*/
private void closeButtonActionPerformed(ActionEvent e) {
this.dispose();
}
}