Sat Nov 27, 2010 10:58 pm
import java.util.Date;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
public class GUILogger {
private static GUILogger logger = null;
private static final JTextArea textArea = new JTextArea(7, 50);
private static final JScrollPane TextAreaScroll = new JScrollPane
(textArea, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
private GUILogger() {
}
public static GUILogger getInstance() {
if (logger == null) {
logger = new GUILogger();
}
return logger;
}
public void logInfo(String info) {
textArea.append("\n" + new Date() + ": " + info);
}
public static GUILogger getLogger() {
return logger;
}
public static void setLogger(GUILogger logger) {
GUILogger.logger = logger;
}
public static JScrollPane getTextAreaScroll() {
return TextAreaScroll;
}
public static JTextArea getTextArea() {
return textArea;
}
}
import java.awt.BorderLayout;
import javax.swing.JPanel;
public class LogPanel extends JPanel {
private GUILogger gUILogger = GUILogger.getInstance();
public LogPanel() {
add(gUILogger.getTextAreaScroll());
}
}
|
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com
Powered by phpBB © phpBB Group.