private void addHTML(String html) { synchronized (kit) { try { kit.insertHTML(doc, doc.getLength(), html, 0, 0, null); } catch (BadLocationException | IOException ignored) { Logger.logError(ignored.getMessage(), ignored); } displayArea.setCaretPosition(displayArea.getDocument().getLength()); } }
private synchronized void refreshLogs() { doc = new HTMLDocument(); displayArea.setDocument(doc); List<LogEntry> entries = Logger.getLogEntries(); StringBuilder logHTML = new StringBuilder(); for (LogEntry entry : entries) { logHTML.append(getMessage(entry)); } addHTML(logHTML.toString()); }
private void createUIComponents() { displayArea = new JEditorPane("text/html", ""); displayArea.setEditable(false); kit = new HTMLEditorKit(); displayArea.setEditorKit(kit); JScrollPane scrollPane = new JScrollPane(displayArea); scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); logType = ELogType.valueOf(SettingsUtils.getValue(ESetting.LOGTYPE)); refreshLogs(); Logger.addListener(this); System.setOut(new OutputOverride(System.out, LogLevel.INFO)); System.setErr(new OutputOverride(System.err, LogLevel.ERROR)); try { Logger.addListener(new LogWriter(new File(launcherLogFile))); } catch (IOException e1) { Logger.logError(e1.getMessage(), e1); } }