diff --git a/src/main/java/com/wudji/lessonlist/MainActivity.java b/src/main/java/com/wudji/lessonlist/MainActivity.java
index fb98a29..502dc89 100644
--- a/src/main/java/com/wudji/lessonlist/MainActivity.java
+++ b/src/main/java/com/wudji/lessonlist/MainActivity.java
@@ -1,14 +1,17 @@
package com.wudji.lessonlist;
+import com.wudji.lessonlist.screens.MainWindow;
+import com.wudji.lessonlist.screens.NoticeScreen;
+import com.wudji.lessonlist.screens.PoemScreen;
+import com.wudji.lessonlist.screens.WelcomeScreen;
+import com.wudji.lessonlist.utils.ExceptionManager;
+import com.wudji.lessonlist.utils.FileControl;
+import com.wudji.lessonlist.obj.WindowConfig;
+
import java.awt.*;
import java.text.ParseException;
-import java.util.*;
import java.util.Timer;
-
-import com.wudji.lessonlist.Screens.*;
-import com.wudji.lessonlist.Utils.FileControl;
-import com.wudji.lessonlist.network.PoemNetworkRequest;
-import com.wudji.lessonlist.obj.WindowConfig;
+import java.util.TimerTask;
public class MainActivity {
@@ -16,22 +19,40 @@ public class MainActivity {
public static WindowConfig globalConfig = FileControl.getWindowConfig();
public static Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
public static String base_version = "v1.1.2";
- public static String product_version = "v1.2.0_poem_suggestion_tjyz";
+ public static String product_version = "v1.2.3-poem-suggestion-tjyz";
+ public static PoemScreen poemScreen;
+ public static MainWindow window;
+ public static WelcomeScreen welcomeScreen;
+ public static NoticeScreen noticeScreen;
public static void main(String[] args){
- MainWindow window = new MainWindow((int)d.getWidth() - globalConfig.getPosx(),globalConfig.getPosy(),globalConfig.getWeight(),(int)d.getHeight() - globalConfig.getHeight());
- WelcomeScreen welcomeScreen = new WelcomeScreen();
- NoticeScreen noticeScreen = new NoticeScreen(window.getLocation());
+ Thread.setDefaultUncaughtExceptionHandler(new CustomExceptionHandler());
+
+ window = new MainWindow((int)d.getWidth() - globalConfig.getPosx(),globalConfig.getPosy(),globalConfig.getWeight(),(int)d.getHeight() - globalConfig.getHeight());
+ welcomeScreen = new WelcomeScreen();
+ noticeScreen = new NoticeScreen(window.getLocation());
Timer timer = new Timer();
if (globalConfig.isEnablePoemSuggestion()){
Thread thread = new Thread(() -> {
- String data = PoemNetworkRequest.getPoemData();
- System.out.println(data);
- PoemScreen poemScreen = new PoemScreen(window.getLocation(),data);
+ Thread.setDefaultUncaughtExceptionHandler(new CustomExceptionHandler());
+
+ poemScreen = new PoemScreen(window.getLocation());
noticeScreen.updatePosition(poemScreen.getHeight());
poemScreen.setVisible(true);
+
+ timer.schedule(new TimerTask() {
+ @Override
+ public void run() {
+ refreshPoemInfo(poemScreen);
+ }
+
+ private void refreshPoemInfo(PoemScreen poemScreen){
+
+ poemScreen.updatePoemInfo();
+ }
+ }, 3600000,3600000);
});
thread.start();
}
@@ -40,10 +61,10 @@ public static void main(String[] args){
timer.schedule(new TimerTask() {
@Override
public void run() {
- showDelayScreen(welcomeScreen, noticeScreen);
+ showDelayScreen();
}
- private void showDelayScreen(WelcomeScreen welcomeScreen,NoticeScreen noticeScreen){
+ private void showDelayScreen(){
// 隐藏欢迎页面
welcomeScreen.setVisible(false);
@@ -52,7 +73,7 @@ private void showDelayScreen(WelcomeScreen welcomeScreen,NoticeScreen noticeScre
noticeScreen.setVisible(true);
}
}
- },(int) (Math.random()*2000));
+ }, 3000);
welcomeScreen.setVisible(true);
@@ -61,15 +82,22 @@ private void showDelayScreen(WelcomeScreen welcomeScreen,NoticeScreen noticeScre
@Override
public void run() {
try {
- updateA(window);
+ updateA();
} catch (ParseException e) {
e.printStackTrace();
}
}
- private void updateA(MainWindow w) throws ParseException {
- w.update();
+ private void updateA() throws ParseException {
+ window.update();
}
},1,1000);
}
+}
+class CustomExceptionHandler implements Thread.UncaughtExceptionHandler{
+
+ @Override
+ public void uncaughtException(Thread t, Throwable e) {
+ ExceptionManager.showErrorDialog(e);
+ }
}
\ No newline at end of file
diff --git a/src/main/java/com/wudji/lessonlist/Screens/AboutScreen.java b/src/main/java/com/wudji/lessonlist/Screens/AboutScreen.java
index 29fa927..1570d82 100644
--- a/src/main/java/com/wudji/lessonlist/Screens/AboutScreen.java
+++ b/src/main/java/com/wudji/lessonlist/Screens/AboutScreen.java
@@ -1,7 +1,7 @@
-package com.wudji.lessonlist.Screens;
+package com.wudji.lessonlist.screens;
import com.wudji.lessonlist.MainActivity;
-import com.wudji.lessonlist.Utils.FileControl;
+import com.wudji.lessonlist.utils.FileControl;
import javax.swing.*;
import java.awt.*;
diff --git a/src/main/java/com/wudji/lessonlist/Screens/GeneralConfigScreen.java b/src/main/java/com/wudji/lessonlist/Screens/GeneralConfigScreen.java
index d60ea00..6332020 100644
--- a/src/main/java/com/wudji/lessonlist/Screens/GeneralConfigScreen.java
+++ b/src/main/java/com/wudji/lessonlist/Screens/GeneralConfigScreen.java
@@ -1,13 +1,13 @@
-package com.wudji.lessonlist.Screens;
+package com.wudji.lessonlist.screens;
import com.wudji.lessonlist.MainActivity;
-import com.wudji.lessonlist.Utils.FileControl;
+import com.wudji.lessonlist.utils.FileControl;
import com.wudji.lessonlist.obj.WindowConfig;
import javax.swing.*;
import java.awt.*;
-public class GeneralConfigScreen extends JFrame {
+public class GeneralConfigScreen extends JDialog {
private WindowConfig config = MainActivity.globalConfig;
private JTextField clockFontSizeField;
private JTextField lessonFontSizeField;
@@ -30,11 +30,12 @@ public class GeneralConfigScreen extends JFrame {
private JTextField noticeHeightField;
public GeneralConfigScreen() {
+ super((Frame) null, "通用配置界面", true);
initialize();
}
private void initialize() {
- setTitle("通用配置页面");
+ // setTitle("通用配置页面");
setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
setResizable(false);
@@ -323,6 +324,20 @@ private void saveConfig(boolean isRestart) {
dispose(); // Close the config window
+ if(!MainActivity.globalConfig.isEnablePoemSuggestion()){
+ MainActivity.poemScreen.setVisible(false);
+ MainActivity.noticeScreen.updatePosition(-1);
+ }else{
+ MainActivity.poemScreen.setVisible(true);
+ MainActivity.noticeScreen.updatePosition(MainActivity.poemScreen.getHeight());
+ }
+
+ if(!MainActivity.globalConfig.isEnableNotice()){
+ MainActivity.noticeScreen.setVisible(false);
+ }else{
+ MainActivity.noticeScreen.setVisible(true);
+ }
+
if(isRestart){
System.exit(0);
}
diff --git a/src/main/java/com/wudji/lessonlist/Screens/LessonConfigScreen.java b/src/main/java/com/wudji/lessonlist/Screens/LessonConfigScreen.java
index 469eefd..7654a7e 100644
--- a/src/main/java/com/wudji/lessonlist/Screens/LessonConfigScreen.java
+++ b/src/main/java/com/wudji/lessonlist/Screens/LessonConfigScreen.java
@@ -1,29 +1,30 @@
-package com.wudji.lessonlist.Screens;
+package com.wudji.lessonlist.screens;
-import com.wudji.lessonlist.Utils.ExceptionManager;
-import com.wudji.lessonlist.Utils.FileControl;
+import com.wudji.lessonlist.utils.ExceptionManager;
+import com.wudji.lessonlist.utils.FileControl;
import com.wudji.lessonlist.obj.Lesson;
import com.wudji.lessonlist.obj.LessonConfig;
import javax.swing.*;
import java.awt.*;
-public class LessonConfigScreen extends JFrame {
+public class LessonConfigScreen extends JDialog {
private Lesson[] lessons;
- private LessonConfig[] configs = new LessonConfig[10];
+ private LessonConfig[] configs = new LessonConfig[15];
private int dateOfWeek;
private static String[] weeks = {"Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"};
public LessonConfigScreen(Lesson[] lessons,String date) {
+ super((Frame) null, "课程配置界面", true);
this.lessons = lessons;
this.dateOfWeek = getDateNumFromString(date);
initialize();
}
private void initialize() {
- setTitle("配置课程列表页面");
+ // setTitle("配置课程列表页面");
setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
setResizable(false);
@@ -88,7 +89,7 @@ private void initialize() {
panel.add(headLabel5, constraints);
// 添加课表配置项
- for (int j = 0;j < 10;j++){
+ for (int j = 0;j < 15;j++){
if(j < lessons.length) {
configs[j] = new LessonConfig(lessons[j], true);
}else {
@@ -114,7 +115,7 @@ private void initialize() {
saveButton.setFont(titleFont);
saveButton.addActionListener(e -> saveConfig(false));
constraints.gridx = 0;
- constraints.gridy = 14;
+ constraints.gridy = 19;
constraints.gridwidth = 3;
panel.add(saveButton, constraints);
@@ -123,7 +124,7 @@ private void initialize() {
saveARButton.addActionListener(e -> saveConfig(true));
constraints.gridx = 2;
- constraints.gridy = 14;
+ constraints.gridy = 19;
constraints.gridwidth = 3;
panel.add(saveARButton, constraints);
diff --git a/src/main/java/com/wudji/lessonlist/Screens/MainConfigScreen.java b/src/main/java/com/wudji/lessonlist/Screens/MainConfigScreen.java
index 65a0103..288c36b 100644
--- a/src/main/java/com/wudji/lessonlist/Screens/MainConfigScreen.java
+++ b/src/main/java/com/wudji/lessonlist/Screens/MainConfigScreen.java
@@ -1,18 +1,22 @@
-package com.wudji.lessonlist.Screens;
+package com.wudji.lessonlist.screens;
-import com.wudji.lessonlist.Utils.FileControl;
+import com.wudji.lessonlist.utils.FileControl;
-import javax.swing.*;
+import javax.swing.JButton;
+import javax.swing.JComboBox;
+import javax.swing.JDialog;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
import java.awt.*;
-public class MainConfigScreen extends JFrame {
+public class MainConfigScreen extends JDialog {
Font fontS = FileControl.getFont(Font.BOLD,20);
Font fontL = FileControl.getFont(Font.BOLD,26);
String targetDay = "Monday";
public MainConfigScreen(){
- setTitle("主配置页面");
- setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
+ super((Frame) null, "主配置界面", true);
+ setDefaultCloseOperation(JDialog.HIDE_ON_CLOSE);
setResizable(false);
JPanel panel = new JPanel();
diff --git a/src/main/java/com/wudji/lessonlist/Screens/MainWindow.java b/src/main/java/com/wudji/lessonlist/Screens/MainWindow.java
index 5ff3646..9438970 100644
--- a/src/main/java/com/wudji/lessonlist/Screens/MainWindow.java
+++ b/src/main/java/com/wudji/lessonlist/Screens/MainWindow.java
@@ -1,10 +1,10 @@
-package com.wudji.lessonlist.Screens;
+package com.wudji.lessonlist.screens;
-import com.wudji.lessonlist.Utils.ClockButtonManager;
-import com.wudji.lessonlist.Utils.ExceptionManager;
+import com.wudji.lessonlist.utils.ClockButtonManager;
+import com.wudji.lessonlist.utils.ExceptionManager;
import com.wudji.lessonlist.MainActivity;
-import com.wudji.lessonlist.Utils.FileControl;
+import com.wudji.lessonlist.utils.FileControl;
import com.wudji.lessonlist.obj.Lesson;
import javax.swing.*;
diff --git a/src/main/java/com/wudji/lessonlist/Screens/NoticeScreen.java b/src/main/java/com/wudji/lessonlist/Screens/NoticeScreen.java
index 2a139ee..27e6863 100644
--- a/src/main/java/com/wudji/lessonlist/Screens/NoticeScreen.java
+++ b/src/main/java/com/wudji/lessonlist/Screens/NoticeScreen.java
@@ -1,8 +1,8 @@
-package com.wudji.lessonlist.Screens;
+package com.wudji.lessonlist.screens;
import com.wudji.lessonlist.MainActivity;
import com.wudji.lessonlist.obj.NoticeLine;
-import com.wudji.lessonlist.Utils.FileControl;
+import com.wudji.lessonlist.utils.FileControl;
import javax.swing.*;
import javax.swing.border.Border;
@@ -44,7 +44,12 @@ public NoticeScreen(Point mainWindowLocation) {
public void updatePosition(int y){
this.pack();
- this.setLocation(this.location.x - this.getWidth(), this.location.y + y + 30);
+ if(y == -1){ // 未启用诗词推送页面
+ this.setLocation(this.location.x - this.getWidth(), this.location.y);
+ }else{
+ this.setLocation(this.location.x - this.getWidth(), this.location.y + y + 30);
+ }
+
}
private void updateNoticeList(NoticeLine[] lines){
panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
diff --git a/src/main/java/com/wudji/lessonlist/Screens/PoemDetailScreen.java b/src/main/java/com/wudji/lessonlist/Screens/PoemDetailScreen.java
index 4d550e8..f64782a 100644
--- a/src/main/java/com/wudji/lessonlist/Screens/PoemDetailScreen.java
+++ b/src/main/java/com/wudji/lessonlist/Screens/PoemDetailScreen.java
@@ -1,34 +1,42 @@
-package com.wudji.lessonlist.Screens;
+package com.wudji.lessonlist.screens;
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;
-import com.wudji.lessonlist.Utils.FileControl;
+import com.wudji.lessonlist.MainActivity;
+import com.wudji.lessonlist.utils.FileControl;
+import com.wudji.lessonlist.network.PoemNetworkRequest;
import javax.swing.*;
import java.awt.*;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
import java.util.Objects;
-public class PoemDetailScreen extends JFrame {
+public class PoemDetailScreen extends JDialog {
private JLabel contentLabel;
+ private String deviceInfo = PoemNetworkRequest.getDeviceInfo();
+
+ static JButton refreshButton = new JButton("🔄 换句新的诗词");
+
public PoemDetailScreen(String json, int fontSize) {
+ super((Frame) null, "诗歌详细信息", true);
- setTitle("诗歌详细信息");
- setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
- setLocationRelativeTo(null);
+ // setTitle("诗歌详细信息");
+ setDefaultCloseOperation(JDialog.HIDE_ON_CLOSE);
+ // setLocationRelativeTo(null);
+ Font font = FileControl.getFont(Font.PLAIN, fontSize);
GridBagLayout gridBagLayout = new GridBagLayout();
setLayout(gridBagLayout);
GridBagConstraints constraints = new GridBagConstraints();
contentLabel = new JLabel();
- contentLabel.setFont(FileControl.getFont(Font.PLAIN, fontSize));
+ contentLabel.setFont(font);
contentLabel.setVerticalAlignment(SwingConstants.TOP);
constraints.gridx = 0;
constraints.gridy = 0;
- constraints.weightx = 1.0;
- constraints.weighty = 1.0;
constraints.fill = GridBagConstraints.BOTH;
add(new JScrollPane(contentLabel), constraints);
@@ -36,7 +44,42 @@ public PoemDetailScreen(String json, int fontSize) {
contentLabel.setFont(FileControl.getFont(Font.PLAIN, fontSize));
+ constraints.gridx = 0;
+ constraints.gridy = 1;
+
+ refreshButton.setFont(new Font(null,Font.BOLD,16));
+ refreshButton.setBackground(new Color(242,242,242));
+ add(refreshButton,constraints);
+ DelayedButtonEnabler enabler = new DelayedButtonEnabler(refreshButton, 120000);
+ refreshButton.addActionListener(enabler);
+
+ constraints.gridx = 0;
+ constraints.gridy = 2;
+ JButton infoButton = new JButton("⚙ 获取实时客户端信息");
+ infoButton.setFont(new Font(null,Font.BOLD,16));
+ infoButton.setBackground(new Color(242,242,242));
+ infoButton.addActionListener(e ->{
+ Thread t = new Thread(()->{
+ PoemRawScreen pr = new PoemRawScreen(PoemNetworkRequest.getDeviceInfo());
+ pr.setVisible(true);
+ });
+ t.start();
+ });
+ add(infoButton,constraints);
+
+ constraints.gridx = 0;
+ constraints.gridy = 3;
+ JButton returnButton = new JButton("🔎 显示源返回信息");
+ returnButton.setFont(new Font(null,Font.BOLD,16));
+ returnButton.setBackground(new Color(242,242,242));
+ add(returnButton,constraints);
+ returnButton.addActionListener(e ->{
+ PoemRawScreen pr = new PoemRawScreen(json);
+ pr.setVisible(true);
+ });
+
pack();
+
}
private void displayJsonContent(String json) {
@@ -68,14 +111,14 @@ private void displayJsonContent(String json) {
// suggestReason
- JSONArray suggestReasonArray = full.getJSONObject("data").getJSONArray("matchTags");
+ JSONArray suggestReasonArray = JSONObject.parseObject(deviceInfo).getJSONObject("data").getJSONArray("tags");
StringBuilder suggestReasonBuilder = new StringBuilder();
for (Object suggestObj : suggestReasonArray) {
suggestReasonBuilder.append(suggestObj.toString()).append(" | ");
}
String suggestReason = suggestReasonBuilder.toString();
- String displayText = ""+ title +"
" + content + "
翻译:
" + translation + "
推荐理由(基于设备地理信息及天气、节气信息):
" + suggestReason + "
Token:
"+ full.getString("token") + "";
+ String displayText = ""+ title +"
" + content + "
翻译:
" + translation + "
设备标签(基于设备地理信息及天气、节气信息):
" + suggestReason + "
Token:
"+ full.getString("token") + "";
contentLabel.setText(displayText);
}else if(Objects.equals(full.getString("status"), "error")){
@@ -87,3 +130,32 @@ private void displayJsonContent(String json) {
}
}
+
+class DelayedButtonEnabler implements ActionListener {
+ private JButton button;
+ private Timer timer;
+
+ public DelayedButtonEnabler(JButton button, int delayMilliseconds) {
+ this.button = button;
+
+ timer = new Timer(delayMilliseconds, e -> enableButton());
+ timer.setRepeats(false);
+ }
+
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ disableButton();
+ MainActivity.poemScreen.updatePoemInfo();
+ ((JButton) e.getSource()).setText("已刷新,操作冷却中(120s)...");
+ timer.start();
+ }
+
+ private void disableButton() {
+ button.setEnabled(false);
+ }
+
+ private void enableButton() {
+ button.setEnabled(true);
+ button.setText("换句新的诗词");
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/com/wudji/lessonlist/Screens/PoemScreen.java b/src/main/java/com/wudji/lessonlist/Screens/PoemScreen.java
index 5d7cb71..6ba2aca 100644
--- a/src/main/java/com/wudji/lessonlist/Screens/PoemScreen.java
+++ b/src/main/java/com/wudji/lessonlist/Screens/PoemScreen.java
@@ -1,25 +1,26 @@
-package com.wudji.lessonlist.Screens;
+package com.wudji.lessonlist.screens;
-import com.alibaba.fastjson2.JSON;
+import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;
import com.wudji.lessonlist.MainActivity;
-import com.wudji.lessonlist.Utils.FileControl;
+import com.wudji.lessonlist.utils.FileControl;
+import com.wudji.lessonlist.network.PoemNetworkRequest;
import com.wudji.lessonlist.obj.NoticeLine;
import javax.swing.*;
import javax.swing.border.Border;
import javax.swing.border.LineBorder;
import java.awt.*;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.awt.geom.RoundRectangle2D;
import java.util.Objects;
public class PoemScreen extends JDialog {
JPanel panel = new JPanel();
String poemDataString;
- public PoemScreen(Point mainWindowLocation, String poemInfoString) {
+ Point location;
+ public PoemScreen(Point mainWindowLocation) {
+
+ this.location = mainWindowLocation;
this.setTitle("诗词显示窗口");
@@ -40,9 +41,7 @@ public PoemScreen(Point mainWindowLocation, String poemInfoString) {
panel.setBorder(customBorder);
- this.poemDataString = poemInfoString;
-
- this.updatePoemInfo(resultResolve());
+ this.updatePoemInfo();
pack();
@@ -50,42 +49,65 @@ public PoemScreen(Point mainWindowLocation, String poemInfoString) {
}
- private void updatePoemInfo(NoticeLine[] lines){
+ public void updatePoemInfo(){
+ panel.removeAll();
+ poemDataString = PoemNetworkRequest.getPoemData();
+ System.out.println(poemDataString);
panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
- for (NoticeLine line : lines) {
+
+ for (NoticeLine line : resultResolve()) {
JLabel label = new JLabel(line.getMessageInfo());
switch (line.getTextStyle()){
case "bold":
- label.setFont(FileControl.getFont(Font.BOLD,MainActivity.globalConfig.getNoticeFontSize()));
+ label.setFont((FileControl.getFont(Font.BOLD,(int)(MainActivity.globalConfig.getNoticeFontSize() * 0.9))));
break;
case "italic":
- label.setFont(FileControl.getFont(Font.ITALIC,MainActivity.globalConfig.getNoticeFontSize()));
+ label.setFont(FileControl.getFont(Font.ITALIC,(int)(MainActivity.globalConfig.getNoticeFontSize() * 0.7)));
break;
case "default":
default:
- label.setFont(FileControl.getFont(Font.PLAIN,MainActivity.globalConfig.getNoticeFontSize()));
+ label.setFont(FileControl.getFont(Font.PLAIN,(int)(MainActivity.globalConfig.getNoticeFontSize() * 0.7)));
}
label.setForeground(line.getFontColor());
panel.add(label);
}
- // add refresh buttons
- JButton refreshButton = new JButton("🔎 诗词信息");
- refreshButton.setFont(new Font(null, Font.PLAIN, 16));
+ // 标签行解析
+ JSONArray suggestReasonArray = JSONObject.parseObject(poemDataString).getJSONObject("data").getJSONArray("matchTags");
+ StringBuilder suggestReasonBuilder = new StringBuilder();
+ for (Object suggestObj : suggestReasonArray) {
+ suggestReasonBuilder.append(suggestObj.toString()).append(" | ");
+ }
+ JLabel reasonLabel = new JLabel("诗词标签: " + suggestReasonBuilder.toString());
+ reasonLabel.setFont(FileControl.getFont(Font.PLAIN,(int)(MainActivity.globalConfig.getNoticeFontSize() * 0.6)));
+ panel.add(reasonLabel);
+ // 添加信息按钮
+ JButton refreshButton = new JButton("🔎 诗词信息");
+ refreshButton.setFont(new Font(null, Font.PLAIN, (int)(MainActivity.globalConfig.getNoticeFontSize() * 0.6)));
+ refreshButton.setBackground(new Color(238,238,238));
refreshButton.addActionListener(e -> {
- PoemDetailScreen poemDetailScreen = new PoemDetailScreen(poemDataString,MainActivity.globalConfig.getNoticeFontSize());
- poemDetailScreen.setVisible(true);
+ Thread thread = new Thread(()->{
+ PoemDetailScreen poemDetailScreen = new PoemDetailScreen(poemDataString,(int)(MainActivity.globalConfig.getNoticeFontSize() * 0.8));
+ poemDetailScreen.setVisible(true);
+ });
+
+ thread.start();
});
panel.add(refreshButton);
- this.add(panel);
+ add(panel);
+ this.pack();
+
+ this.setLocation(location.x - this.getWidth(), location.y);
+
+ this.validate();
+ this.repaint();
}
private NoticeLine[] resultResolve(){
NoticeLine[] poemInfo = new NoticeLine[2];
-
-
+ // 诗歌句子解析
JSONObject fullData = JSONObject.parseObject(poemDataString);
// System.out.println(fullData.getString("status"));
if(Objects.equals(fullData.getString("status"), "success")){
diff --git a/src/main/java/com/wudji/lessonlist/Screens/WPanel.java b/src/main/java/com/wudji/lessonlist/Screens/WPanel.java
index 12a661f..43837c9 100644
--- a/src/main/java/com/wudji/lessonlist/Screens/WPanel.java
+++ b/src/main/java/com/wudji/lessonlist/Screens/WPanel.java
@@ -1,4 +1,4 @@
-package com.wudji.lessonlist.Screens;
+package com.wudji.lessonlist.screens;
import javax.swing.*;
import java.awt.*;
diff --git a/src/main/java/com/wudji/lessonlist/Screens/WelcomeScreen.java b/src/main/java/com/wudji/lessonlist/Screens/WelcomeScreen.java
index bd78364..43163c2 100644
--- a/src/main/java/com/wudji/lessonlist/Screens/WelcomeScreen.java
+++ b/src/main/java/com/wudji/lessonlist/Screens/WelcomeScreen.java
@@ -1,4 +1,4 @@
-package com.wudji.lessonlist.Screens;
+package com.wudji.lessonlist.screens;
import javax.swing.*;
import java.awt.*;
diff --git a/src/main/java/com/wudji/lessonlist/Utils/ClockButtonManager.java b/src/main/java/com/wudji/lessonlist/Utils/ClockButtonManager.java
index e0a788a..8fbed2f 100644
--- a/src/main/java/com/wudji/lessonlist/Utils/ClockButtonManager.java
+++ b/src/main/java/com/wudji/lessonlist/Utils/ClockButtonManager.java
@@ -1,7 +1,7 @@
-package com.wudji.lessonlist.Utils;
+package com.wudji.lessonlist.utils;
import com.wudji.lessonlist.MainActivity;
-import com.wudji.lessonlist.Screens.MainConfigScreen;
+import com.wudji.lessonlist.screens.MainConfigScreen;
import javax.swing.*;
import java.awt.*;
@@ -16,8 +16,8 @@ public class ClockButtonManager {
static SimpleDateFormat formatter= new SimpleDateFormat("HH:mm:ss");
- static Font font1 = FileControl.getFont(Font.BOLD, MainActivity.globalConfig.getClockFontsize() -1);
- static Font font2 = FileControl.getFont(Font.BOLD, MainActivity.globalConfig.getClockFontsize() -1);
+ static Font font1 = FileControl.getFont(Font.BOLD, MainActivity.globalConfig.getClockFontsize() - 1);
+ static Font font2 = FileControl.getFont(Font.BOLD, MainActivity.globalConfig.getClockFontsize() - 1);
public static JButton getTimeButton(){
JButton j = new JButton(" 时间:" + formatter.format(new Date(System.currentTimeMillis())) +" ");
@@ -39,8 +39,9 @@ public static JButton getWeekButton(int week){
public static JButton getCountdownButton(){
Date d = Calendar.getInstance().getTime();
- LocalDateTime dateStart = LocalDateTime.of(MainActivity.globalConfig.getCountDownYear(), MainActivity.globalConfig.getCountDownMonth() - 1 , MainActivity.globalConfig.getCountDownDate(),8,1);
- LocalDateTime dateEnd = LocalDateTime.of(d.getYear() + 1900, d.getMonth(), d.getDate(), 0, 1);
+ // fix #1: 当日期形如10月31日时,dateEnd计算出错。
+ LocalDateTime dateStart = LocalDateTime.of(MainActivity.globalConfig.getCountDownYear(), MainActivity.globalConfig.getCountDownMonth() , MainActivity.globalConfig.getCountDownDate(),8,1);
+ LocalDateTime dateEnd = LocalDateTime.of(d.getYear() + 1900, d.getMonth() + 1, d.getDate(), 0, 1);
Duration duration = Duration.between(dateStart, dateEnd);
diff --git a/src/main/java/com/wudji/lessonlist/Utils/ExceptionManager.java b/src/main/java/com/wudji/lessonlist/Utils/ExceptionManager.java
index 7e4cf8d..3845e00 100644
--- a/src/main/java/com/wudji/lessonlist/Utils/ExceptionManager.java
+++ b/src/main/java/com/wudji/lessonlist/Utils/ExceptionManager.java
@@ -1,11 +1,10 @@
-package com.wudji.lessonlist.Utils;
+package com.wudji.lessonlist.utils;
import com.wudji.lessonlist.MainActivity;
import javax.swing.*;
import java.io.PrintWriter;
import java.io.StringWriter;
-import java.lang.reflect.Field;
public class ExceptionManager {
public static void showErrorDialog(Throwable throwable) {
@@ -17,7 +16,7 @@ public static void showErrorDialog(Throwable throwable) {
throwable.printStackTrace(pw);
String stackTrace = sw.toString();
- String errorMessage = throwable.getMessage();
+ String errorMessage = "