private void removeTags() { if (editorPane.getContentType().equals("text/html")) { editorPane.setText(htmlContents); editorPane.revalidate(); editorPane.repaint(); } else { DefaultStyledDocument doc = (DefaultStyledDocument)editorPane.getDocument(); SimpleAttributeSet attr = new SimpleAttributeSet(); StyleConstants.setForeground(attr, Color.BLACK); StyleConstants.setBackground(attr, Color.WHITE); doc.setCharacterAttributes(0, doc.getLength(), attr, false); } saveTaggedAs.setEnabled(false); }
private void removeTags() { if (editorPane.getContentType().equals("text/html")) { if (htmlContents != null) { editorPane.setText(htmlContents); } editorPane.revalidate(); editorPane.repaint(); } else { DefaultStyledDocument doc = (DefaultStyledDocument)editorPane.getDocument(); SimpleAttributeSet attr = new SimpleAttributeSet(); StyleConstants.setForeground(attr, Color.BLACK); StyleConstants.setBackground(attr, Color.WHITE); doc.setCharacterAttributes(0, doc.getLength(), attr, false); } saveTaggedAs.setEnabled(false); }
String text = null; try { text = doc.getText(0, doc.getLength()); } catch (Exception e) { throw new RuntimeException(e);
String text = null; try { text = doc.getText(0, doc.getLength()); } catch (Exception e) { log.err(e);
private void resetNewlineRequired() { if (doc.getLength() == 0) { newlineRequired = false; } }
DefaultStyledDocument document = (DefaultStyledDocument) jTextPane1.getDocument(); try { contText = document.getText(0, document.getLength()); } catch (BadLocationException ex) { Logger.getLogger(JTextPaneTest.class.getName()).log(Level.SEVERE, null, ex); }
private void scrollDown3() { try { int endPosition = doc.getLength(); Rectangle bottom = modelToView(endPosition); if (bottom != null) { bottom.height = bottom.height + 100; scrollRectToVisible(bottom); } } catch (BadLocationException ex) { LOGGER.warning("Bad Location"); } }
public void clearAll() { try { doc.remove(0, doc.getLength()); resetNewlineRequired(); kit.clearImages(); } catch (BadLocationException ex) { Logger.getLogger(ChannelTextPane.class.getName()).log(Level.SEVERE, null, ex); } }
/** * Removes any prior style changes used to highlight a search result. */ private void clearSearchResult() { doc.setCharacterAttributes(0, doc.getLength(), styles.clearSearchResult(), false); }
/** * Start the next print with a newline. This must be called when the current * line is finished. */ protected void finishLine() { newlineRequired = true; lineSelection.onLineAdded(getLastLine(doc)); even = !even; setVariableLineAttributes(doc.getLength() - 1, even, true); }
private void createNewPiper() { final DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern( "MMMM dd, yyyy" ); final LocalDate date = LocalDate.now(); final String text = "// *** Piper File ***\n" + "// Created by " + System.getProperty( "user.name" ) + "\n" + "// on " + date.format( dateFormatter ) + "\n\n"; try { _piperDocument.remove( 0, _piperDocument.getLength() ); _piperDocument.insertString( 0, text, null ); _textPane.setCaretPosition( _piperDocument.getLength() ); } catch ( BadLocationException blE ) { LOGGER.warn( blE.getMessage() ); } _runButton.setEnabled( false ); }
private void addSym(String text){ String[] lines = text.split(String.valueOf(ChatColor.COLOR_CHAR)); for (int i = 1; i < lines.length; i++){ String line = lines[i]; String key = line.substring(0, 1); String theText = line.substring(1); AttributeSet attribute = attributes.get(key); try{ int len = doc.getLength(); doc.insertString(len, theText, attribute); }catch (BadLocationException e){ e.printStackTrace(); } } chat.setCaretPosition(chat.getDocument().getLength()); } }
private void addCom(String text){ AttributeSet attribute = attributes.get("0"); try{ int len = doc.getLength(); doc.insertString(len, text, attribute); }catch (BadLocationException e){ e.printStackTrace(); } chat.setCaretPosition(chat.getDocument().getLength()); }
protected void initializeReader() throws IOException { InputStream in; try { in = blob.getStream(); } catch (RepositoryException e) { throw new IOException(e.getMessage()); } try { doc.remove(0, doc.getLength()); rek.read(in, doc, 0); String text = doc.getText(0, doc.getLength()); delegate = new StringReader(text); } catch (BadLocationException e) { throw new IOException(e.getMessage()); } finally { in.close(); } } };
/** * {@inheritDoc} */ public Reader extractText(InputStream stream, String type, String encoding) throws IOException { try { RTFEditorKit rek = new RTFEditorKit(); DefaultStyledDocument doc = new DefaultStyledDocument(); rek.read(stream, doc, 0); String text = doc.getText(0, doc.getLength()); return new StringReader(text); } catch (BadLocationException e) { logger.warn("Failed to extract RTF text content", e); return new StringReader(""); } finally { stream.close(); } } }
private void updatePatterns() { final String text = loggerConfigTextPane.getText(); final List<LogPattern> resultList = getLogPatterns(text); try { styledDocument.remove(0, styledDocument.getLength()); for (LogPattern result : resultList) { resultTextPane.insertIcon(result.isValid() ? Icons.STATUS_OK : Icons.STATUS_ERROR); styledDocument.insertString(styledDocument.getLength(), " " + result.getPattern() + "\n", defaultStyle); } } catch (BadLocationException ignore) { } if (resultList.isEmpty()) { resultTextPane.setText("No logger patterns detected in project opened in IDE."); } }
private void setOldState() throws BadLocationException { TextState oldState = new TextState.Builder(getText(0, super.getLength()), inputPane.getCaretPosition()).build(); OLD_STATE.set(oldState); } }
public void setDocument(DefaultStyledDocument doc) { try { // System.out.println(this.getClass().getName() + " - setDocument(" + doc + ")"); m_document.removeDocumentListener(this); m_document = doc; m_tune = m_parser.parse(doc.getText(0, doc.getLength())); m_document.addDocumentListener(this); } catch (Exception e) { e.printStackTrace(); } }
public void removeOldLines() { if (messageTimeout > 0) { Element paragraph = doc.getDefaultRootElement().getElement(0); if (doc.getLength() > 1 && getTimeAgo(paragraph) > messageTimeout * 1000) { // removeFirstLines(1); // Don't use doc.remove() for this, since removing one line with // it seems to copy paragraph attributes to the follow line // (visible if alternating backgrounds are showing) if (doc.getDefaultRootElement().getElementCount() > 1) { // Can't use this if it's the last element doc.removeElement(doc.getDefaultRootElement().getElement(0)); } else { clearAll(); } scrollDownIfNecessary(); resetNewlineRequired(); } } }