DELL
2024-08-30 9792926a4a3054f1b2f72e6fc8c810103bb81c16
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
package main;
 
import javax.swing.JPanel;
 
import java.awt.BorderLayout;
 
import javax.swing.JLabel;
import javax.swing.JScrollBar;
import javax.swing.JScrollPane;
import javax.swing.ScrollPaneConstants;
import javax.swing.JTextArea;
import java.awt.Font;
 
public class page_debug_inf extends JPanel {
    /**
     * 
     */
    private static final long serialVersionUID = 1L;
    private JTextArea ta_debug;
    private JScrollPane scrollPane;
    private JLabel label;
    /**
     * Create the panel.
     */
    public page_debug_inf() {
        setLayout(new BorderLayout(0, 0));
        
        label = new JLabel(" \u4FE1\u606F\u884C\u6570");
        add(label, BorderLayout.NORTH);
        
        scrollPane = new JScrollPane();
        scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
        add(scrollPane, BorderLayout.CENTER);
        
        ta_debug = new JTextArea();
        ta_debug.setFont(new Font("Courier New", Font.PLAIN, 13));
        scrollPane.setViewportView(ta_debug);
 
    }
    
    public void addDebugInf(String inf) {
        ta_debug.append(inf);
        int line_cnt = ta_debug.getLineCount();
        label.setText("ÐÅÏ¢ÐÐÊý: " + line_cnt);
        if(line_cnt > 1000) {
            ta_debug.setText(inf);
        }
        
        JScrollBar scrollBar = scrollPane.getVerticalScrollBar();
        scrollBar.setValue(scrollBar.getMaximum());
    }
}