wenzheng.yang
2023-06-19 8d3a46d346ef028acc16e267fe5c812c76a754e5
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
package publicclass;
import java.awt.Color;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import java.util.Timer;
import java.util.TimerTask;
import javax.swing.ImageIcon;
import javax.swing.JDialog;
import javax.swing.JPanel;
import javax.swing.JProgressBar;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
public class Open_soft_dialog   extends JDialog implements WindowListener{
 
    /**
     * 
     */
    private static final long serialVersionUID = 1L;
    
    JPanel jp_mb=null;//ÉêÃ÷Ò»¸öÃæ°å
    JScrollPane js_gd=null;//¹ö¶¯Ãæ°å
    static JTextArea jt_are=null;
    static JProgressBar progressBar;
    static boolean succ=false;
    JButtonModel close=null;
    Timer timer;
    {
        getJt_are();
    }
    public  Open_soft_dialog() {
        String name="Êý¾ÝÕýÔÚ¼ÓÔØÖÐÇëÉÔºó(Data is loading)...";
        this.setAlwaysOnTop(true);//×ÜÊÇÖö¥
        Toolkit toolkit = getToolkit();// »ñµÃ´°Ì幤¾ß°ü
        Dimension screenSize = toolkit.getScreenSize();// »ñÈ¡ÆÁÄ»´óС
        int width = (int) (screenSize.width* 0.5);// ¼ÆËã´°Ìåпí¶È
        int height = (int) (screenSize.height * 0.5);// ¼ÆËã´°Ìåпí¶È
        int x0=width-180;//´°Ìåx0×ø±ê
        int y0=height-180;//´°Ìåy0×ø±ê
        Container rq=getContentPane();
        rq.setBackground(UIColor.getBlues());
        rq.add(getJp_mb());
        this.setTitle(name);
        this.setBounds(x0, y0,470,310);
        this.setVisible(true);
        this.setIconImage(new ImageIcon("image/icon/anchoricon.png").getImage());
        ding_shi_qi();
    }
    
    public void close() {
        jt_are=null;
        this.dispose();
    }
    
    
 
    public JPanel getJp_mb() {
        if(jp_mb==null) {
            jp_mb=new JPanel();
            jp_mb.setLayout(null);
            jp_mb.setBackground(UIColor.getBlues());
            get_progressBar().setBounds(85,40,220,30);
            getClose().setBounds(85+230,40,80,30);
            getJs_gd().setBounds(85, 90,300,150);
            jp_mb.add(progressBar);            
            jp_mb.add(js_gd);
            jp_mb.add(getClose());    
            jp_mb.addMouseListener(new MouseListener() {
                public void mouseReleased(MouseEvent e) {
                    if(succ) {
                        close();
                    }
                }
                
                @Override
                public void mousePressed(MouseEvent e) {
                    if(succ) {
                        close();
                    }
                }
                
                @Override
                public void mouseExited(MouseEvent e) {
                    if(succ) {
                        close();
                    }
                }
                
                @Override
                public void mouseEntered(MouseEvent e) {
                    if(succ) {
                        close();
                    }
                }
                
                @Override
                public void mouseClicked(MouseEvent e) {
                    if(succ) {
                        close();
                    }
                }
            });
            
        }
        return jp_mb;
    }
    
    /**Ìí¼Ó±êÇ©ÐÅÏ¢*/
    public static void addara(String message) {
        jt_are.append(GetNowTime.HH_MM_SS()+":"+message+"...\n");
        jt_are.setCaretPosition(jt_are.getText().length());
    }
 
    public JScrollPane getJs_gd() {
        if(js_gd==null) {
            js_gd=new JScrollPane(getJt_are());
            js_gd.setBorder(null);
        }
        return js_gd;
    }
 
    public static JTextArea getJt_are() {
        if(jt_are==null) {
            jt_are=new JTextArea();
            
        }
        return jt_are;
    }
    
    public static JProgressBar get_progressBar() {
        if(progressBar==null) {
            progressBar=new JProgressBar ();
            progressBar.setStringPainted(true);
            progressBar.setIndeterminate(true);
            progressBar.setPreferredSize(new Dimension(300, 30));
            progressBar.setFont(new Font("΢ÈíÑźÚ", Font.PLAIN, 16));
            progressBar.setBackground(Color.green);            
            
        }
        return progressBar;
    }
 
    public static void setSucc(boolean succ) {
        Open_soft_dialog.succ = succ;
    }
 
    @Override
    public void windowOpened(WindowEvent e) {
        // TODO ×Ô¶¯Éú³ÉµÄ·½·¨´æ¸ù
        
    }
 
    @Override
    public void windowClosing(WindowEvent e) {
        // TODO ×Ô¶¯Éú³ÉµÄ·½·¨´æ¸ù
        
        
    }
 
    @Override
    public void windowClosed(WindowEvent e) {
        // TODO ×Ô¶¯Éú³ÉµÄ·½·¨´æ¸ù
        
    }
 
    @Override
    public void windowIconified(WindowEvent e) {
        // TODO ×Ô¶¯Éú³ÉµÄ·½·¨´æ¸ù
        
    }
 
    @Override
    public void windowDeiconified(WindowEvent e) {
        // TODO ×Ô¶¯Éú³ÉµÄ·½·¨´æ¸ù
        
    }
 
    @Override
    public void windowActivated(WindowEvent e) {
        // TODO ×Ô¶¯Éú³ÉµÄ·½·¨´æ¸ù
        
    }
 
    @Override
    public void windowDeactivated(WindowEvent e) {
        // TODO ×Ô¶¯Éú³ÉµÄ·½·¨´æ¸ù
        
    }
    
    
    /**¶¨Ê±Æ÷*/
    public  void ding_shi_qi() {
        Integer cacheTime = 1000;//´¥·¢Æ÷ʱ¼ä100ºÁÃëÖ´ÐÐÒ»´Î
        timer = new Timer(); 
        timer.schedule(new TimerTask() { 
            @Override  
            public void run() {  
                try { 
                    if(succ) {
                        close();
                        timer.cancel();
                    }
                    
                } catch (Exception e) {
                    // TODO ×Ô¶¯Éú³ÉµÄ catch ¿é
                    e.printStackTrace();
                }  
            }  
        }, 1000, cacheTime);  
 
    }
 
    public JButtonModel getClose() {
        if(close==null) {
            close=new JButtonModel("Í˳ö³ÌÐò");
            close.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    System.exit(0);                    
                }
            });
            
        }
        return close;
    }
 
    public void setClose(JButtonModel close) {
        this.close = close;
    }
 
}