📄 mylogging.java
字号:
package main;
//Copyright (C) 2008 Harald Unander, Wang Wenjuan
//
// This file is part of WlanTV.
//
// WlanTV is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// WlanTV is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with WlanTV. If not, see <http://www.gnu.org/licenses/>.
import java.awt.Color;
import java.awt.Dimension;
import java.util.LinkedHashSet;
import java.util.Set;
import javax.swing.BoxLayout;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
@SuppressWarnings("serial")
public class MyLogging extends JPanel {
JTextArea ta;
JScrollPane sa;
String nl = "";
Set<String> msgSet = new LinkedHashSet<String>();
public MyLogging()
{
ta = new JTextArea();
// ta.setFont(getFont().deriveFont(Font.ITALIC));
ta.setForeground(Color.RED);
sa = new JScrollPane(ta);
add(sa);
sa.setPreferredSize(new Dimension(0,50));
setVisible(true);
setLayout(new BoxLayout(this,BoxLayout.X_AXIS));
}
public void addWarning(Object object, String msg) {
String line;
if (object != null)
line = object.getClass().getCanonicalName()+" : "+msg;
else
line = msg;
if (!msgSet.contains(line)) {
msgSet.add(line);
ta.setText("");
nl = "";
for (String s : msgSet)
{
ta.append(nl+s);
ta.setCaretPosition(ta.getDocument().getLength());
nl = "\n";
}
}
}
public void clear() {
ta.setText("");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -