Skip to content
This repository was archived by the owner on May 5, 2025. It is now read-only.

Commit f245c91

Browse files
committed
add generate HTML
function
1 parent 79b0b27 commit f245c91

File tree

2 files changed

+77
-2
lines changed

2 files changed

+77
-2
lines changed
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,77 @@
11
package top.mryan2005.managesysteminjava.BasicClass;
22

3+
import javax.swing.*;
4+
import java.util.ArrayList;
5+
36
public class Entry {
7+
public String simplified_Chinese_character; // 简体中文字符
8+
public String traditional_Chinese_character; // 繁体中文字符
9+
public String Pronunciation_of_Wuzhou; // 梧州话发音
10+
public String Pronunciation_of_Cangwu_Shiqiao; // 苍梧石桥话发音
11+
public String Pronunciation_of_Mengshan; // 蒙山话发音
12+
public String Heterozygous_Ancient_Texts_of_the_Same_Type; // 同类异文
13+
public String Radical_simplified; // 简体部首
14+
public String Radical_traditional; // 繁体部首
15+
public String finalUpdateDate; // 最后更新日期
16+
public int total_number_of_strokes_simplified; // 简体笔画总数
17+
public int total_number_of_strokes_traditional; // 繁体笔画总数
18+
public int total_number_of_radical_strokes_simplified; // 简体部首笔画总数
19+
public int total_number_of_radical_strokes_traditional; // 繁体部首笔画总数
20+
public String html; // HTML代码
21+
public ArrayList<String> Contributors; // 贡献者
22+
public String generateHTML() {
23+
html = "<html><head>" +
24+
"<style type=\"text/css\">" +
25+
"body {font-family: 'Microsoft YaHei';}" +
26+
"h1 {font-size: 22px;}" +
27+
"h2 {font-size: 20px;}" +
28+
"h3 {font-size: 16px;}" +
29+
"p {font-size: 14px;}" +
30+
"</style>" +
31+
"</head><body>" +
32+
"<h1>" + simplified_Chinese_character + "</h1>" +
33+
"<h2>" + traditional_Chinese_character + "</h2>" +
34+
"<p>梧州话发音:" + Pronunciation_of_Wuzhou + "</p>" +
35+
"<p>苍梧石桥话发音:" + Pronunciation_of_Cangwu_Shiqiao + "</p>" +
36+
"<p>蒙山话发音:" + Pronunciation_of_Mengshan + "</p>" +
37+
"<p>同类异文:" + Heterozygous_Ancient_Texts_of_the_Same_Type + "</p>" +
38+
"<p>简体部首:" + Radical_simplified + "</p>" +
39+
"<p>繁体部首:" + Radical_traditional + "</p>" +
40+
"<p>简体笔画总数:" + total_number_of_strokes_simplified + "</p>" +
41+
"<p>繁体笔画总数:" + total_number_of_strokes_traditional + "</p>" +
42+
"<p>简体部首笔画总数:" + total_number_of_radical_strokes_simplified + "</p>" +
43+
"<p>繁体部首笔画总数:" + total_number_of_radical_strokes_traditional + "</p>" +
44+
"<p>最后更新日期:" + finalUpdateDate + "</p>" +
45+
"<hr />" +
46+
"<h3>贡献者</h3>";
47+
for(String contributor : Contributors) {
48+
html += "<p>@" + contributor + "</p>";
49+
}
50+
html += "</body></html>";
51+
return html;
52+
}
53+
public static void main(String[] args) {
54+
Entry entry = new Entry();
55+
entry.simplified_Chinese_character = "你";
56+
entry.traditional_Chinese_character = "你";
57+
entry.Pronunciation_of_Wuzhou = "ni";
58+
entry.Pronunciation_of_Cangwu_Shiqiao = "ni";
59+
entry.Pronunciation_of_Mengshan = "ni";
60+
entry.Heterozygous_Ancient_Texts_of_the_Same_Type = "你";
61+
entry.Radical_simplified = "人";
62+
entry.Radical_traditional = "人";
63+
entry.finalUpdateDate = "2024-11-08";
64+
entry.total_number_of_strokes_simplified = 7;
65+
entry.total_number_of_strokes_traditional = 7;
66+
entry.total_number_of_radical_strokes_simplified = 2;
67+
entry.total_number_of_radical_strokes_traditional = 2;
68+
entry.Contributors = new ArrayList<>();
69+
entry.Contributors.add("mryan2005");
70+
entry.Contributors.add("gungbbogedding");
71+
JFrame frame = new JFrame();
72+
frame.setSize(800, 600);
73+
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
74+
frame.add(new JLabel(entry.generateHTML()));
75+
frame.setVisible(true);
76+
}
477
}

src/main/java/top/mryan2005/managesysteminjava/Core.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -742,8 +742,10 @@ public void actionPerformed(ActionEvent e) {
742742
Object[][] data;
743743
try {
744744
ResultSet res = sql.runSQL("SELECT * FROM entry.viewAll WHERE simplified_Chinese_character LIKE '%" + input[0] + "%' UNION SELECT * FROM entry.viewAll WHERE traditional_Chinese_character LIKE '%" + input[0] + "%'");
745-
while (res.next()) {
746-
l.add(new Object[]{res.getString("id"), res.getString("simplified_Chinese_character"), res.getString("traditional_Chinese_character"), res.getString("Pronunciation_of_Wuzhou"), res.getString("Pronunciation_of_Cangwu_Shiqiao"), res.getString("Pronunciation_of_Mengshan")});
745+
if (res != null) {
746+
while (res.next()) {
747+
l.add(new Object[]{res.getString("id"), res.getString("simplified_Chinese_character"), res.getString("traditional_Chinese_character"), res.getString("Pronunciation_of_Wuzhou"), res.getString("Pronunciation_of_Cangwu_Shiqiao"), res.getString("Pronunciation_of_Mengshan")});
748+
}
747749
}
748750
data = new Object[l.size()][6];
749751
for (int i = 0; i < l.size(); i++) {

0 commit comments

Comments
 (0)