-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJav_info
48 lines (40 loc) · 1.2 KB
/
Jav_info
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
package nguyenvanquan7826;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import javax.swing.JFrame;
import javax.swing.JTextArea;
public class CaroInfo extends JFrame {
private String direction = File.separator + "nguyenvanquan7826"
+ File.separator + "textInfo" + File.separator;
private String[] fileName = { "caroHelp", "caroAbout" };
private String[] title = { "Hướng dẫn", "Giới thiệu" };
public CaroInfo() {
}
public CaroInfo(int type) {
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
setSize(400, 300);
setTitle("Caro - " + title[type]);
// add content
add(createJTextArea(type));
setLocationRelativeTo(null);
setVisible(true);
}
private JTextArea createJTextArea(int type) {
InputStream in = getClass().getResourceAsStream(
direction + fileName[type]);
System.out.println(direction + fileName[type]);
JTextArea ta = new JTextArea();
ta.setWrapStyleWord(true);
ta.setLineWrap(true);
ta.setEditable(false);
ta.setBackground(null);
try {
ta.read(new InputStreamReader(in), null);
} catch (IOException e) {
System.out.println("Error read file");
}
return ta;
}
}