public void run () { ui.textArea.append(text + "\n"); ui.textArea.setCaretPosition(ui.textArea.getDocument().getLength()); } });
public void run () { ui.textArea.append("" + c); ui.textArea.setCaretPosition(ui.textArea.getDocument().getLength()); } });
@Override public void focusLost(FocusEvent e) { notesChanged(notesEditor.getDocument()); }
Document document = textArea.getDocument(); int findLength = find.length(); try {
notesEditor.getDocument().addUndoableEditListener(e -> undoRedo.addEdit(e.getEdit()));
@Override public void write(int b) throws IOException { // redirects data to the text area textArea.append(String.valueOf((char)b)); // scrolls the text area to the end of data textArea.setCaretPosition(textArea.getDocument().getLength()); } }
/** Clears the current text. */ private void onClear() { int len = textArea.getDocument().getLength(); if (len > 0) { try { textArea.getDocument().remove(0, len); } catch (BadLocationException ex) { // this shouldn't happen throw new IllegalStateException(ex); } } }
@Override public void write(byte[] bytes, int off, int len) throws IOException { String str = new String(bytes, off, len); systemOut.append(str); logField.append(str); logField.setCaretPosition(logField.getDocument().getLength()); }
@Override public void write(int b) throws IOException { String str = new String(new char[] { (char) b }); systemOut.append(str); logField.append(str); logField.setCaretPosition(logField.getDocument().getLength()); } });
private void onCopyToClipboard() { if (textArea.getDocument().getLength() > 0) { StringSelection sel = new StringSelection(textArea.getText()); Clipboard clip = Toolkit.getDefaultToolkit().getSystemClipboard(); clip.setContents(sel, sel); } }
/** * Appends the given text to that displayed. No additional newlines are added after the * text. * * @param text the text to append * @param indent indent width as number of spaces */ private void append(final String text, final int indent) { String appendText; if (indent > 0) { char[] c = new char[indent]; Arrays.fill(c, ' '); String pad = String.valueOf(c); appendText = pad + text.replaceAll("\\n", "\n" + pad); } else { appendText = text; } textArea.append(appendText); textArea.setCaretPosition(textArea.getDocument().getLength()); }
@Override public void onMessage(MessageType messageType, String message) { java.awt.EventQueue.invokeLater(() -> { boolean verbose = messageType == MessageType.VERBOSE; if (!verbose || showVerboseOutputCheckBox.isSelected()) { String verboseS = "[" + Localization.getString("verbose") + "]"; consoleTextArea.append((verbose ? verboseS : "") + message); if (consoleTextArea.isVisible() && scrollWindowCheckBox.isSelected()) { consoleTextArea.setCaretPosition(consoleTextArea.getDocument().getLength()); } } }); }
/** * Returns the text in which to search, as a string. This is used * internally to grab the smallest buffer possible in which to search. */ private static String getFindInText(JTextArea textArea, int start, boolean forward) { // Be smart about the text we grab to search in. We grab more than // a single line because our searches can return multi-line results. // We copy only the chars that will be searched through. String findIn = null; try { if (forward) { findIn = textArea.getText(start, textArea.getDocument().getLength()-start); } else { // backward findIn = textArea.getText(0, start); } } catch (BadLocationException ble) { // Never happens; findIn will be null anyway. ble.printStackTrace(); } return findIn; }
private void checkScrollWindow() { // Console output. DefaultCaret caret = (DefaultCaret)consoleTextArea.getCaret(); if (scrollWindowCheckBox.isSelected()) { caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE); consoleTextArea.setCaretPosition(consoleTextArea.getDocument().getLength()); } else { caret.setUpdatePolicy(DefaultCaret.NEVER_UPDATE); } // Command table. this.commandTable.setAutoWindowScroll(scrollWindowCheckBox.isSelected()); }
private void checkScrollWindow() { // Console output. DefaultCaret caret = (DefaultCaret)consoleTextArea.getCaret(); if (scrollWindowMenuItem.isSelected()) { caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE); consoleTextArea.setCaretPosition(consoleTextArea.getDocument().getLength()); } else { caret.setUpdatePolicy(DefaultCaret.NEVER_UPDATE); } }
/** * When new messages are created this method will be called. * It will decide using the {@code messageType} if the message should be written to the console. * * @param messageType the type of message to be written * @param message the message to be written to the console */ @Override public void onMessage(MessageType messageType, String message) { java.awt.EventQueue.invokeLater(() -> { boolean verbose = MessageType.VERBOSE.equals(messageType); if (!verbose || showVerboseMenuItem.isSelected()) { if (verbose) { consoleTextArea.append("[" + messageType.getLocalizedString() + "] "); } consoleTextArea.append(message); if (consoleTextArea.isVisible() && scrollWindowMenuItem.isSelected()) { consoleTextArea.setCaretPosition(consoleTextArea.getDocument().getLength()); } } }); }
private void onSave() { int len = textArea.getDocument().getLength(); if (len > 0) { Writer writer = null;
this.textInput.setLineWrap(true); this.textInput.getDocument().addDocumentListener(new DocumentListenerTyping() {
@Override public void execute() { if (MediatorGui.panelConsoles() == null) { LOGGER.error("Unexpected unregistered MediatorGui.panelConsoles() in "+ this.getClass()); } MediatorGui.panelConsoles().getBinaryTab().append("\t"+ this.text); MediatorGui.panelConsoles().getBinaryTab().setCaretPosition(MediatorGui.panelConsoles().getBinaryTab().getDocument().getLength()); int tabIndex = MediatorGui.tabConsoles().indexOfTab("Boolean"); if (0 <= tabIndex && tabIndex < MediatorGui.tabConsoles().getTabCount()) { Component tabHeader = MediatorGui.tabConsoles().getTabComponentAt(tabIndex); if (MediatorGui.tabConsoles().getSelectedIndex() != tabIndex) { tabHeader.setFont(tabHeader.getFont().deriveFont(Font.BOLD)); } } }
@Override public void execute() { if (MediatorGui.panelConsoles() == null) { LOGGER.error("Unexpected unregistered MediatorGui.panelConsoles() in "+ this.getClass()); } try { MediatorGui.panelConsoles().getChunkTab().append(this.text +"\n"); MediatorGui.panelConsoles().getChunkTab().setCaretPosition(MediatorGui.panelConsoles().getChunkTab().getDocument().getLength()); int tabIndex = MediatorGui.tabConsoles().indexOfTab("Chunk"); if (0 <= tabIndex && tabIndex < MediatorGui.tabConsoles().getTabCount()) { Component tabHeader = MediatorGui.tabConsoles().getTabComponentAt(tabIndex); if (MediatorGui.tabConsoles().getSelectedIndex() != tabIndex) { tabHeader.setFont(tabHeader.getFont().deriveFont(Font.BOLD)); } } } catch(ArrayIndexOutOfBoundsException e) { // Fix #4770 on chunkTab.append() LOGGER.error(e.getMessage(), e); } }