0.2.5b fix

1.bug修复
This commit is contained in:
jianguo 2024-05-23 15:23:53 +08:00
parent 7653f15af1
commit 667fa242d3
4 changed files with 12 additions and 13 deletions

View File

@ -6,7 +6,7 @@
<groupId>org.aohe</groupId>
<artifactId>sane-service</artifactId>
<version>0.2.5</version>
<version>0.2.5-b</version>
<properties>
<maven.compiler.source>21</maven.compiler.source>

View File

@ -4,7 +4,7 @@ import java.io.IOException;
import lombok.extern.slf4j.Slf4j;
import org.aohe.core.sane.utils.SaneSessionUtils;
import org.aohe.core.swing.LogWindow;
import org.aohe.core.swing.MainWindow;
import org.aohe.core.utils.CommandUtils;
import org.aohe.core.utils.SystemUtils;
import org.aohe.core.web.SocketFactory;
@ -25,7 +25,7 @@ public class Main {
}
//初始化其他资源
init();
SwingUtilities.invokeLater(() -> new LogWindow().setVisible(true));
SwingUtilities.invokeLater(() -> new MainWindow().setVisible(true));
}

View File

@ -5,16 +5,15 @@ import org.aohe.core.web.SocketFactory;
import javax.swing.*;
import java.awt.*;
import java.net.UnknownHostException;
@Slf4j
public class LogWindow extends JFrame {
public class MainWindow extends JFrame {
private static boolean serviceStatus = false;
private static JTextArea logTextArea;
public LogWindow() {
public MainWindow() {
// 设置窗口标题
setTitle("扫描仪控制器");
@ -44,7 +43,8 @@ public class LogWindow extends JFrame {
getContentPane().add(scrollPane, BorderLayout.CENTER);
JLabel textField = new JLabel();
textField.setText("服务状态:" + getServiceStatus());
textField.setForeground(Color.GRAY);
textField.setText("服务状态:未知");
JPanel bottomPanel = new JPanel();
@ -58,6 +58,7 @@ public class LogWindow extends JFrame {
initSocket();
setView("服务已打开...");
serviceStatus = true;
textField.setForeground(Color.GREEN);
textField.setText("服务状态:" + getServiceStatus());
});
stopButton.addActionListener(e -> {
@ -68,6 +69,7 @@ public class LogWindow extends JFrame {
stopSocket();
serviceStatus = false;
startButton.setEnabled(true);
textField.setForeground(Color.RED);
textField.setText("服务状态:" + getServiceStatus());
}).start();
@ -91,7 +93,7 @@ public class LogWindow extends JFrame {
log.error("出错了 " , e);
throw new RuntimeException(e);
}
SwingUtilities.invokeLater(() -> new LogWindow().setVisible(true));
SwingUtilities.invokeLater(() -> new MainWindow().setVisible(true));
}
public static String getServiceStatus() {

View File

@ -20,8 +20,6 @@ public class SocketFactory {
@Getter
private static SocketServer socketServer;
private static SocketFactory instance ;
private SocketFactory() {
}
@ -53,9 +51,8 @@ public class SocketFactory {
*/
public static void stop(){
try {
SocketServer server = getSocketServer();
if(server != null){
server.stop();
if(socketServer != null){
socketServer.stop();
}
} catch (InterruptedException e) {
throw new RuntimeException(e);