| | |
| | | import java.util.ResourceBundle; |
| | | import dell_targets.Dell_tag; |
| | | import publicsWay.Languages; |
| | | import publicsWay.UDPPortAReceiver; |
| | | import udptcp.UDPPortAReceiver; |
| | | import udptcp.UDPPortBReceiver; |
| | | |
| | | public class MessageViewPanel extends JPanel { |
| | |
| | | private JRadioButton rdoSendHex; |
| | | private JRadioButton rdoSendAscii; |
| | | private JCheckBox chkAppendNewline; |
| | | // 添加常量定义最大行数 |
| | | private static final int MAX_LINES = 10000; |
| | | private static final int TRIM_LINES = 5000; // 当超过最大行数时保留的行数 |
| | | |
| | | private static final ThreadLocal<StringBuilder> SB = |
| | | ThreadLocal.withInitial(() -> new StringBuilder(256)); |
| | |
| | | "ALL", |
| | | "55AA01", "55AA02", "55AA03", "55AA05", "55AA07", |
| | | "55AA0A", "55AA0C", "55AA12", "55AA14", "55AA20", |
| | | "GNGGA", "XTB" |
| | | "GNGGA", "XTB", "GBGGA", "SSGGA" |
| | | }); |
| | | protocolPanel.add(cbProtocol, BorderLayout.CENTER); |
| | | add(protocolPanel, gbc); |
| | |
| | | |
| | | SwingUtilities.invokeLater(() -> { |
| | | txtDataView.append(displayData.toString() + "\n"); |
| | | |
| | | // 检查并限制行数 |
| | | int lineCount = txtDataView.getLineCount(); |
| | | if (lineCount > MAX_LINES) { |
| | | try { |
| | | int end = txtDataView.getLineEndOffset(TRIM_LINES - 1); |
| | | txtDataView.replaceRange("", 0, end); |
| | | } catch (Exception ex) { |
| | | ex.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | txtDataView.setCaretPosition(txtDataView.getDocument().getLength()); |
| | | }); |
| | | } |
| | |
| | | SwingUtilities.invokeLater(() -> { |
| | | txtDataView.append(finalText); |
| | | txtDataView.append("\n"); |
| | | |
| | | // 检查并限制行数 |
| | | int lineCount = txtDataView.getLineCount(); |
| | | if (lineCount > MAX_LINES) { |
| | | try { |
| | | int end = txtDataView.getLineEndOffset(TRIM_LINES - 1); |
| | | txtDataView.replaceRange("", 0, end); |
| | | } catch (Exception ex) { |
| | | ex.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | txtDataView.setCaretPosition(txtDataView.getDocument().getLength()); |
| | | }); |
| | | |