From a6077217e25f5804027194a5c2848e773eda1abd Mon Sep 17 00:00:00 2001
From: 张世豪 <979909237@qq.com>
Date: 星期五, 21 十一月 2025 15:47:17 +0800
Subject: [PATCH] 修改

---
 src/dialog/Dingshidialog.java |   45 +++++++++++++++++++++++++++++++++++++--------
 1 files changed, 37 insertions(+), 8 deletions(-)

diff --git a/src/xitongshezhi/Dingshidialog.java b/src/dialog/Dingshidialog.java
similarity index 86%
rename from src/xitongshezhi/Dingshidialog.java
rename to src/dialog/Dingshidialog.java
index 6a564c2..f821c1d 100644
--- a/src/xitongshezhi/Dingshidialog.java
+++ b/src/dialog/Dingshidialog.java
@@ -1,4 +1,4 @@
-package xitongshezhi;
+package dialog;
 
 import java.awt.BorderLayout;
 import java.awt.Color;
@@ -26,6 +26,9 @@
  */
 public class Dingshidialog {
     
+    // 娣诲姞闈欐�佹爣蹇楁潵璺熻釜寮圭獥鏄剧ず鐘舵��
+    private static volatile boolean isDialogShowing = false;
+    
     /**
      * 鏄剧ず瀹氭椂鍏抽棴瀵硅瘽妗�
      * @param parent 鐖剁獥鍙�
@@ -34,8 +37,14 @@
      * @param audioFile MP3鏂囦欢鍚嶏紙鏍圭洰褰曚笅锛屾棤闇�鎵╁睍鍚嶏級
      * @return 1-鎴愬姛 0-澶辫触
      */
-    public static int showTimedDialog(Frame parent, int countdownTime, String message, String audioFile) {
-        TimedDialog dialog = new TimedDialog(parent, countdownTime, message, audioFile);
+    public static int showTimedDialog(Frame parent, int countdownTime, String message) {
+        // 妫�鏌ユ槸鍚﹀凡鏈夊脊绐楀湪鏄剧ず
+        if (isDialogShowing) {
+            System.out.println("宸叉湁寮圭獥鍦ㄦ樉绀猴紝蹇界暐鏂拌姹�");
+            return 0; // 杩斿洖澶辫触
+        }
+        
+        TimedDialog dialog = new TimedDialog(parent, countdownTime, message);
         return dialog.showDialog();
     }
     
@@ -43,19 +52,18 @@
      * 鍐呴儴瀵硅瘽妗嗙被锛岀‘淇濅娇鐢ㄥ悗鑳借鍨冨溇鍥炴敹
      */
     @SuppressWarnings("serial")
-	private static class TimedDialog extends JDialog {
+    private static class TimedDialog extends JDialog {
         private JLabel countdownLabel;
         private int remainingTime;
         private int result = 0;
         private Clip audioClip;
         private volatile boolean running = true;
         
-        public TimedDialog(Frame parent, int countdownTime, String message, String audioFile) {
+        public TimedDialog(Frame parent, int countdownTime, String message) {
             super(parent, "", true);
             this.remainingTime = countdownTime;
             initializeUI(message);
             startCountdown();
-            playAudio(audioFile);
         }
         
         private void initializeUI(String message) {
@@ -89,7 +97,7 @@
             messageLabel.setHorizontalAlignment(SwingConstants.CENTER);
 
             // 鍒涘缓鍊掕鏃舵爣绛�
-            countdownLabel = new JLabel("鍓╀綑鏃堕棿: " + remainingTime + "绉�");
+            countdownLabel = new JLabel(remainingTime + "绉掑悗鑷姩鍏抽棴");
             countdownLabel.setFont(new Font("Microsoft YaHei", Font.BOLD, 16));
             countdownLabel.setForeground(new Color(231, 76, 60));
             countdownLabel.setHorizontalAlignment(SwingConstants.CENTER);
@@ -132,6 +140,18 @@
                 public void windowClosing(java.awt.event.WindowEvent e) {
                     disposeDialog();
                 }
+                
+                @Override
+                public void windowOpened(java.awt.event.WindowEvent e) {
+                    // 璁剧疆寮圭獥鏄剧ず鏍囧織
+                    isDialogShowing = true;
+                }
+                
+                @Override
+                public void windowClosed(java.awt.event.WindowEvent e) {
+                    // 纭繚寮圭獥鍏抽棴鏃堕噸缃爣蹇�
+                    isDialogShowing = false;
+                }
             });
         }
         
@@ -147,7 +167,7 @@
                         
                         SwingUtilities.invokeLater(() -> {
                             if (countdownLabel != null) {
-                                countdownLabel.setText("鍓╀綑鏃堕棿: " + remainingTime + "绉�");
+                                countdownLabel.setText( remainingTime + "绉掑悗鑷姩鍏抽棴");
                             }
                         });
                         
@@ -245,6 +265,9 @@
             // 娓呯悊UI寮曠敤
             countdownLabel = null;
             
+            // 閲嶇疆寮圭獥鏄剧ず鏍囧織
+            isDialogShowing = false;
+            
             dispose();
         }
         
@@ -252,6 +275,12 @@
          * 鏄剧ず瀵硅瘽妗�
          */
         public int showDialog() {
+            // 鍐嶆妫�鏌ユ爣蹇楋紝闃叉绔炴�佹潯浠�
+            if (isDialogShowing) {
+                System.out.println("宸叉湁寮圭獥鍦ㄦ樉绀猴紝鍙栨秷鏄剧ず");
+                return 0;
+            }
+            
             setVisible(true);
             return result;
         }

--
Gitblit v1.9.3