-
Notifications
You must be signed in to change notification settings - Fork 0
/
JWC.java
72 lines (58 loc) · 1.7 KB
/
JWC.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
import java.awt.Container;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.HashMap;
import javax.swing.*;
public class JWC extends JFrame{
JTextArea contentArea;
String title;
String content;
String id;
HashMap<String, String> hm;
private Container container;
private FlowLayout layout;
private JButton lastButton;
JWC(){
super( "Get JWC Info" );//set title
container = getContentPane();
container.setLayout(null);
//init do sth
id=JWC_core.getLatestNewsID();
hm =JWC_core.readNews(id);
title = hm.get("title");
//last
lastButton = new JButton("Last");
lastButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
hm = JWC_core.readNews(String.valueOf(Integer.parseInt(id)-1));
title = hm.get("title");
content = hm.get("newsContent");
if(content.isEmpty()){
contentArea.setText("该新闻已被删除");
}else{
contentArea.setText("\n\n"+content);
}
contentArea.setCaretPosition(0);
}
});
container.add(lastButton);
contentArea = new JTextArea(hm.get("newsContent"));
// contentArea.setSize(500, 600);
contentArea.setEditable(false);
contentArea.setLineWrap(true);
contentArea.setCaretPosition(0);
JScrollPane scroll = new JScrollPane(contentArea); //添加滚动条
scroll.setSize(500, 600);
scroll.setVerticalScrollBarPolicy(
JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
container.add(scroll);
setSize(600, 600);
setVisible(true);
}
public static void main(String[] args) {
// TODO Auto-generated method stub
JWC test = new JWC();
test.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
}
}