private void buildContentPanel() { editorPane = new JEditorPane (); editorPane.setContentType("text/rtf"); editorPane.addKeyListener(new InputListener()); // defaultAttrSet = ((StyledEditorKit)editorPane.getEditorKit()).getInputAttributes(); StyleConstants.setFontFamily(defaultAttrSet, "Lucida Sans"); Document doc = new DefaultStyledDocument(); editorPane.setDocument(doc); try { doc.insertString(0, initText, defaultAttrSet); } catch (Exception ex) { throw new RuntimeException(ex); } JScrollPane scrollPane = new JScrollPane(editorPane); frame.getContentPane().add(scrollPane, BorderLayout.CENTER); editorPane.setEditable(true); }
private void buildContentPanel() { editorPane = new JEditorPane (); editorPane.setContentType("text/rtf"); editorPane.addKeyListener(new InputListener()); // defaultAttrSet = ((StyledEditorKit)editorPane.getEditorKit()).getInputAttributes(); StyleConstants.setFontFamily(defaultAttrSet, "Lucinda Sans"); Document doc = new DefaultStyledDocument(); editorPane.setDocument(doc); try { doc.insertString(0, initText, defaultAttrSet); } catch (Exception ex) { throw new RuntimeException(ex); } JScrollPane scrollPane = new JScrollPane(editorPane); frame.getContentPane().add(scrollPane, BorderLayout.CENTER); editorPane.setEditable(true); }
private void clearDocument() { editorPane.setContentType("text/rtf"); Document doc = new DefaultStyledDocument(); editorPane.setDocument(doc); // defaultAttrSet = ((StyledEditorKit)editorPane.getEditorKit()).getInputAttributes(); // StyleConstants.setFontFamily(defaultAttrSet, "Lucinda Sans Unicode"); log.info("attr: "+defaultAttrSet); try { doc.insertString(0, " ", defaultAttrSet); } catch (Exception ex) { throw new RuntimeException(ex); } editorPane.setEditable(true); editorPane.revalidate(); editorPane.repaint(); saveUntagged.setEnabled(false); saveTaggedAs.setEnabled(false); taggedContents = null; htmlContents = null; loadedFile = null; }
public void clearDocument() { editorPane.setContentType("text/rtf"); Document doc = new DefaultStyledDocument(); editorPane.setDocument(doc); // defaultAttrSet = ((StyledEditorKit)editorPane.getEditorKit()).getInputAttributes(); // StyleConstants.setFontFamily(defaultAttrSet, "Lucinda Sans Unicode"); log.info("attr: "+defaultAttrSet); try { doc.insertString(0, " ", defaultAttrSet); } catch (Exception ex) { throw new RuntimeException(ex); } editorPane.setEditable(true); editorPane.revalidate(); editorPane.repaint(); saveUntagged.setEnabled(false); saveTaggedAs.setEnabled(false); taggedContents = null; untaggedContents = null; htmlContents = null; loadedFile = null; }
DefaultStyledDocument doc = new DefaultStyledDocument(); doc.setDocumentFilter(new GroovyFilter(doc)); textEditor.setDocument(doc);
DefaultStyledDocument document = new DefaultStyledDocument(); JTextPane textpane = new JTextPane(document); StyleContext context = new StyleContext(); // build a style Style style = context.addStyle("test", null); // set some style properties StyleConstants.setForeground(style, Color.BLUE); // add some data to the document document.insertString(0, "", style);
JTextPane textPane = new JTextPane(new DefaultStyledDocument()); ((AbstractDocument) textPane.getDocument()).setDocumentFilter(new HighlightDocumentFilter(textPane)); JFrame frame = new JFrame("Test");
private StyledDocument getDocument(InputStream inputStream, String encoding) { StyledDocument docu = new DefaultStyledDocument(); if (inputStream != null) { String data = getStringOfStream(inputStream, encoding); try { docu.insertString(0, data, null); } catch (BadLocationException e) { e.printStackTrace(); } } return docu; }
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); StyledDocument doc = new DefaultStyledDocument(); JTextPane textPane = new JTextPane(doc); textPane.setText("Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has "
private StyledDocument getContentStreamDocument(InputStream inputStream) { StyledDocument docu = new DefaultStyledDocument(); PDFStreamParser parser; try { parser = new PDFStreamParser(IOUtils.toByteArray(inputStream)); parser.parse(); } catch (IOException e) { return null; } for (Object obj : parser.getTokens()) { writeToken(obj, docu); } return docu; }
/** * {@inheritDoc} */ @Override protected Document createDefaultDocument() { return new DefaultStyledDocument(); }
/** * {@inheritDoc} */ @Override protected Document createDefaultDocument() { return new DefaultStyledDocument(); }
public class MainFrame { public MainFrame() { myInitComponents(); } //delete the myInitComponents() method initComponents () { //code useful for the DefaultStyledDocument.. DefaultStyledDocument doc = new DefaultStyledDocument(); //components textModel = new javax.swing.JTextPane(doc); }
JTextPane textPane = new JTextPane(new DefaultStyledDocument() { @Override public void insertString(int offs, String str, AttributeSet a) throws BadLocationException { if ((getLength() + str.length()) <= maxNumberOfCharacters) { super.insertString(offs, str, a); } else { Toolkit.getDefaultToolkit().beep(); } } });
private StyledDocument createNormalDocument(String text) { StyledDocument document = new DefaultStyledDocument(); try { document.insertString(0, text, normalTextStyle); return document; } catch (BadLocationException e) { throw new UiException(e); } }
DefaultStyledDocument doc = new DefaultStyledDocument(); StyleContext sc = new StyleContext(); Style style = sc.addStyle("strikethru", null); StyleConstants.setStrikeThrough (style,true); doc.insertString (0, "Hello ", null); doc.insertString (6, "strike through ", style); JTextPane pane = new JTextPane(doc);
private String convert(InputStream rtfDocumentInputStream) throws IOException { RTFEditorKit aRtfEditorkit = new RTFEditorKit(); StyledDocument styledDoc = new DefaultStyledDocument(); String textDocument; try { aRtfEditorkit.read(rtfDocumentInputStream, styledDoc, 0); textDocument = styledDoc.getText(0, styledDoc.getLength()); } catch (BadLocationException e) { throw new IOException("Error during parsing"); } return textDocument; }
private StyledDocument createNormalDocument(String text) { StyledDocument document = new DefaultStyledDocument(); try { Style style = theme != null ? theme.getNormalTextStyle() : null; document.insertString(0, text, style); return document; } catch (BadLocationException e) { throw new UiException(e); } }
public ATETextPane(ATEPanel textEditor, StyledEditorKit editorKit) { super(new DefaultStyledDocument()); setCaret(new ATECaret()); setEditorKit(editorKit==null?new ATEEditorKit(textEditor):editorKit); this.textEditor = textEditor; }
public MappingValidationDialog(JTree tree) { super(); DialogUtils.installEscapeCloseOperation(this); myself = this; doc = new DefaultStyledDocument(); createStyles(); createContent(); this.setModal(true); // DialogUtils.centerDialogWRTParent(tree.getParent(), this); }