private void drawText(java.util.List<String> strings) { text.setText(""); StyledDocument doc = text.getStyledDocument(); try { for (String line : strings) { doc.insertString(doc.getLength(), line + '\n', doc.getStyle("regular")); } } catch (BadLocationException ble) { } text.setCaretPosition(0); }
protected void drawText() { text.setText(""); StyledDocument doc = text.getStyledDocument(); try { for (String rule : getRules()) { doc.insertString(doc.getLength(), rule + '\n', doc.getStyle("small")); } } catch (BadLocationException e) { } text.setCaretPosition(0); }
/** * {@inheritDoc} */ @Override public Style getStyle(String nm) { return ((StyledDocument) delegate).getStyle(nm); }
/** Returns a named style. @param name The name of the style. @return The style. **/ public synchronized Style getStyle (String name) { return document_.getStyle (name); }
/** * {@inheritDoc} */ public Style getStyle(String nm) { return ((StyledDocument) delegate).getStyle(nm); }
/** * {@inheritDoc} */ @Override public Style getStyle(String nm) { return ((StyledDocument) delegate).getStyle(nm); }
/** * Inserts the specified URL in the specified document. * @param doc document in which to insert the text. * @param url url to insert. * @throws BadLocationException thrown if something wrong happened to the document. */ private static void insertUrl(StyledDocument doc, String url) throws BadLocationException { doc.insertString(doc.getLength(), " ", doc.getStyle(STYLE_NORMAL)); doc.insertString(doc.getLength(), url + LINE_BREAK, doc.getStyle(STYLE_URL)); }
/** * Inserts the specified header in the specified document. * @param doc document in which to insert the text. * @param string text to insert. * @throws BadLocationException thrown if something wrong happened to the document. */ private static void insertHeader(StyledDocument doc, String string) throws BadLocationException { doc.insertString(doc.getLength(), string + LINE_BREAK, doc.getStyle(STYLE_HEADER)); }
/** * Inserts the specified string and details in the specified document. * @param doc document in which to insert the text. * @param string text to insert. * @param details details that will be added to the text. * @throws BadLocationException thrown if something wrong happened to the document. */ private static void insertDetailedString(StyledDocument doc, String string, String details) throws BadLocationException { doc.insertString(doc.getLength(), string + " ", doc.getStyle(STYLE_NORMAL)); doc.insertString(doc.getLength(), "(" + details + ")" + LINE_BREAK, doc.getStyle(STYLE_DETAILS)); }
/** * Inserts the specified string in the specified document. * @param doc document in which to insert the text. * @param string text to insert. * @throws BadLocationException thrown if something wrong happened to the document. */ private static void insertNormalString(StyledDocument doc, String string) throws BadLocationException { doc.insertString(doc.getLength(), string + LINE_BREAK, doc.getStyle(STYLE_NORMAL)); }
/** * Inserts a line break in the specified document. * @param doc document in which to insert the text. * @throws BadLocationException thrown if something wrong happened to the document. */ private static void insertLineBreak(StyledDocument doc) throws BadLocationException { doc.insertString(doc.getLength(), LINE_BREAK, doc.getStyle(STYLE_NORMAL)); }
/** * Redirects the standard output and error streams to the console. */ public void redirectStandardStreams() { System.setOut( new PrintStream( new ConsoleStream( null ) ) ); System.setErr( new PrintStream( new ConsoleStream( _document.getStyle( "error" ) ) ) ); }
/** * This is called when the input color is changed so that all input is added with the * AttributeSet (Style) that has been specified for input. */ private void setInputAttribute() { inputControl.setInputAttributeSet(consoleStyledDocument.getStyle(inputColor)); if (!useInlineInput) { inputArea.setForeground(getStyleColorFromCode(inputColor.charAt(0))); // Foreground inputArea.setBackground(getStyleColorFromCode(inputColor.charAt(1))); // Background } }
/** * This is called when the input color is changed so that all input is added * with the AttributeSet (Style) that has been specified for input. */ private void setInputAttribute() { inputControl.setInputAttributeSet(consoleStyledDocument.getStyle(inputColor)); if (!useInlineInput) { inputArea.setForeground(getStyleColorFromCode(inputColor.charAt(0))); // Foreground inputArea.setBackground(getStyleColorFromCode(inputColor.charAt(1))); // Background } }
private void insert(String text, LineStyle style) { assert ! Log.Dis.cndAsm; try { styledDoc.insertString(styledDoc.getLength(), text, styledDoc.getStyle(style.toString())); } catch (BadLocationException ble2) { System.err.println("View.clear(): Couldn't insert initial text into document."); } }
public void appendLinkText( String linkURL, String linkTitle ) throws BadLocationException { if ( browseWorks && linkURL.matches( "^(?:https?|ftp)://.*" ) ) { SimpleAttributeSet tmpAttr = new SimpleAttributeSet( doc.getStyle( STYLE_HYPERLINK ) ); tmpAttr.addAttribute( ATTR_HYPERLINK_TARGET, linkURL ); doc.insertString( doc.getLength(), linkTitle, tmpAttr ); } else { doc.insertString( doc.getLength(), linkURL, doc.getStyle( STYLE_REGULAR ) ); } }
private static Style getStyleAtPoint(JTextPane text, Point point) { int pos = text.viewToModel(point); StyledDocument doc = text.getStyledDocument(); Element element = doc.getCharacterElement(pos); AttributeSet addtributes = element.getAttributes(); return doc.getStyle((String) addtributes .getAttribute(StyleConstants.NameAttribute)); }
@Override public void mouseMoved(MouseEvent e) { int pos = previewText.viewToModel(e.getPoint()); StyledDocument doc = previewText.getStyledDocument(); Element element = doc.getCharacterElement(pos); AttributeSet addtributes = element.getAttributes(); Style style = doc.getStyle((String) addtributes .getAttribute(StyleConstants.NameAttribute)); previewText.setToolTipText( "Click to change the " + style.getName() + " color"); } });
public static void print(String id, String data){ try { StyledDocument doc = screen.getStyledDocument(); doc.insertString(doc.getLength(), formatForPrint(data), doc.getStyle("receive"+id+"Style")); screen.setCaretPosition(doc.getLength()); } catch (BadLocationException ex) { ex.printStackTrace(); } }
public static void print(String id, String data){ try { StyledDocument doc = screen.getStyledDocument(); doc.insertString(doc.getLength(), formatForPrint(data), doc.getStyle("receive"+id+"Style")); screen.setCaretPosition(doc.getLength()); } catch (BadLocationException ex) { ex.printStackTrace(); } }