congrats Icon
New! Tabnine Pro 14-day free trial
Start a free trial
Tabnine Logo
DefaultStyledDocument
Code IndexAdd Tabnine to your IDE (free)

How to use
DefaultStyledDocument
in
javax.swing.text

Best Java code snippets using javax.swing.text.DefaultStyledDocument (Showing top 20 results out of 540)

Refine searchRefine arrow

  • Container
  • JFrame
  • Window
  • JTextPane
  • JScrollPane
origin: stanfordnlp/CoreNLP

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);
}
origin: stanfordnlp/CoreNLP

String text = null;
try {
 text = doc.getText(0, doc.getLength());
} catch (Exception e) {
 throw new RuntimeException(e);
  try {
   String entity = finalText.substring(start, end);
   doc.setCharacterAttributes(start, entity.length(), attSet, false);
  } catch (Exception ex) {
   throw new RuntimeException(ex);
origin: stackoverflow.com

 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);
origin: stanfordnlp/CoreNLP

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);
}
origin: groovy/groovy-core

  styledDocument.setCharacterAttributes(matchEnd,
                     offset - matchEnd,
                     defaultStyle,
styledDocument.setCharacterAttributes(offset,
                   matchEnd - offset,
                   style, true);
if (styledDocument.getParagraphElement(offset).getStartOffset() !=
  styledDocument.getParagraphElement(matchEnd).getStartOffset()) {
styledDocument.setCharacterAttributes(matchEnd,
                   checkPoint - matchEnd,
                   defaultStyle,
origin: groovy/groovy-core

styledDocument.getText(0, styledDocument.getLength(), segment);
  length = styledDocument.getLength();
origin: stackoverflow.com

private JEditorPane editorPane = new JEditorPane();
private JComboBox<Integer> fontBox = new JComboBox<Integer>(ITEMS);
private StyledDocument doc = new DefaultStyledDocument();
private StyledEditorKit styledEditorKit = new StyledEditorKit();
 editorPane.setDocument(doc);
 editorPane.setEditorKit(styledEditorKit);
 JScrollPane scrollpane = new JScrollPane(editorPane);
 scrollpane.setPreferredSize(new Dimension(500, 400));
 JPanel comboPanel = new JPanel();
 comboPanel.add(fontBox);
 setLayout(new BorderLayout());
 add(scrollpane, BorderLayout.CENTER);
 add(comboPanel, BorderLayout.SOUTH);
 JFrame frame = new JFrame("EditorPaneFun");
 frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
 frame.getContentPane().add(new EditorPaneFun());
 frame.pack();
 frame.setLocationRelativeTo(null);
 frame.setVisible(true);
origin: stackoverflow.com

JFrame frame = new JFrame(TestDifferentStyles.class.getSimpleName());
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 "
    + "been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of "
frame.add(new JScrollPane(textPane));
frame.setSize(500, 400);
frame.setVisible(true);
origin: stackoverflow.com

JFrame f = new JFrame("Styles Example 1");
final DefaultStyledDocument doc = new DefaultStyledDocument(sc);
JTextPane pane = new JTextPane(doc);
        doc.setParagraphAttributes(0, 1, heading2Style, false);
      } catch (BadLocationException e) {
f.getContentPane().add(new JScrollPane(pane));
f.setSize(400, 300);
f.setVisible(true);
origin: stackoverflow.com

JFrame frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(new Dimension(600,200));
frame.getContentPane().setBackground(Color.BLACK);
panel.setLayout(new GridLayout(1, 2));
panel.setBackground(Color.BLACK);
frame.add(panel);
StyledDocument document = new DefaultStyledDocument(context);
JTextPane area = new JTextPane(document);
panel.add(area);
frame.setVisible(true);
origin: stackoverflow.com

  public void run() {
    JFrame frame = initgui();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.pack();
    frame.setVisible(true);
JFrame frame = new JFrame("Test");
JPanel panel = new JPanel();
StyledDocument doc = (StyledDocument) new DefaultStyledDocument();
JTextPane textpane = new JTextPane(doc);
textpane.setText("Test");
javax.swing.text.Style style = textpane.addStyle("Red", null);
StyleConstants.setForeground(style, Color.RED);
doc.setCharacterAttributes(0, 1, textpane.getStyle("Red"), true); 
panel.add(textpane);
frame.add(panel);
return frame;
origin: stackoverflow.com

setDefaultCloseOperation(EXIT_ON_CLOSE);
setSize(400, 400);
setLocationRelativeTo(null);
      if (wordR == after || String.valueOf(text.charAt(wordR)).matches("\\W")) {
        if (text.substring(wordL, wordR).matches("(\\W)*(private|public|protected)"))
          setCharacterAttributes(wordL, wordR - wordL, attr, false);
        else
          setCharacterAttributes(wordL, wordR - wordL, attrBlack, false);
        wordL = wordR;
      setCharacterAttributes(before, after - before, attr, false);
    } else {
      setCharacterAttributes(before, after - before, attrBlack, false);
JTextPane txt = new JTextPane(doc);
txt.setText("public class Hi {}");
add(new JScrollPane(txt));
setVisible(true);
origin: stackoverflow.com

JFrame f = new JFrame("Cool Table");
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.add(new JScrollPane(t));
f.pack();
f.setVisible(true);
if(data[r] instanceof String) {
  try{
    DefaultStyledDocument doc = new DefaultStyledDocument();
    doc.insertString(0, data[r].toString(), null);
    data[r] = doc;
private static Border etchedBorder = BorderFactory.createEtchedBorder();
private JTextComponent styledRenderer = new JTextPane();
private JTextPane styledEditor = new JTextPane();
  editorComponent = new JScrollPane(styledEditor);
      styledEditor.setDocument((Document)val);
origin: stackoverflow.com

this.styledDocument = new DefaultStyledDocument();
this.styledDocument.insertString(0, displayText(), null);
addStylesToDocument(styledDocument);
JFrame frame = new JFrame("JTextPane Test");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setLocationByPlatform(true);
textPane = new JTextPane(styledDocument);
textPane.addCaretListener(new SelectedText());
textPane.setPreferredSize(new Dimension(250, 125));
JScrollPane scrollPane = new JScrollPane(textPane);
frame.add(scrollPane);
frame.pack();
frame.setVisible(true);
origin: stackoverflow.com

this.document = new DefaultStyledDocument();
Runnable runnable = new Runnable() {
  @Override
frame = new JFrame();
frame.setTitle("Huge Text");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.add(new JScrollPane(textArea));
frame.setSize(400, 350);
frame.setLocationRelativeTo(null);
frame.setVisible(true);
origin: stackoverflow.com

JTextPane textPane = new JTextPane(new DefaultStyledDocument());
((AbstractDocument) textPane.getDocument()).setDocumentFilter(new HighlightDocumentFilter(textPane));
JFrame frame = new JFrame("Test");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setLayout(new BorderLayout());
frame.add(new JScrollPane(textPane));
frame.pack();
origin: stackoverflow.com

JFrame frame = new JFrame();
DefaultStyledDocument document = new DefaultStyledDocument();
JTextPane pane = new JTextPane(document);
JPanel mainPanel = new JPanel();
JButton button = new JButton("Button");
button.setPreferredSize(new Dimension(100, 40));
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
pane.setPreferredSize(new Dimension(200, 200));
mainPanel.add(button);
frame.getContentPane().add(pane, BorderLayout.CENTER);
frame.getContentPane().add(mainPanel, BorderLayout.WEST);
StyleContext context = new StyleContext();
frame.pack();
frame.setVisible(true);
origin: stackoverflow.com

@Override
public void run() {
  JFrame frame = new JFrame("Colored Text");
  frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  StyledDocument doc = new DefaultStyledDocument();
  JTextPane textPane = new JTextPane(doc);
  textPane.setText("Different Colored Text");
  for (int i = 0; i < textPane.getDocument().getLength(); i++) {
    SimpleAttributeSet set = new SimpleAttributeSet();
    StyleConstants.setForeground(set,
  frame.add(new JScrollPane(textPane));
  frame.pack();
  frame.setVisible(true);
origin: stackoverflow.com

add(leftBox);
DefaultStyledDocument pd = new DefaultStyledDocument();
SimpleAttributeSet sas = new SimpleAttributeSet();
StyleConstants.setSpaceBelow(sas, spaceBelow);
pd.setParagraphAttributes(0, pd.getLength(), sas, false);
modifiedTA= new JTextPane(pd);  
add(modifiedTA);
final JFrame frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.add(new LineSpacingExample());
frame.pack();
frame.setLocationRelativeTo(null);
frame.setVisible(true);
origin: stackoverflow.com

  StyleConstants.setFontFamily(style, "Helvetica");
  printStyleAttributes(style);
  document.setCharacterAttributes(0, document.getLength(), style, true);
});
JFrame frame = new JFrame("Styling example");
JPanel contentPane = new JPanel();
contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.Y_AXIS));
contentPane.add(editorPane);
contentPane.add(changeStyleButton);
frame.setContentPane(contentPane);
frame.setSize(300,300);
frame.setLocationRelativeTo(null);
frame.setVisible(true);
javax.swing.textDefaultStyledDocument

Most used methods

  • <init>
  • getLength
  • insertString
  • getText
  • remove
  • setCharacterAttributes
  • addDocumentListener
  • setDocumentFilter
  • addUndoableEditListener
  • createPosition
  • getParagraphElement
  • getCharacterElement
  • getParagraphElement,
  • getCharacterElement,
  • setParagraphAttributes,
  • getDefaultRootElement,
  • insert,
  • addStyle,
  • fireInsertUpdate,
  • fireRemoveUpdate,
  • getEndPosition,
  • getStyle

Popular in Java

  • Finding current android device location
  • setContentView (Activity)
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • scheduleAtFixedRate (Timer)
  • Graphics2D (java.awt)
    This Graphics2D class extends the Graphics class to provide more sophisticated control overgraphics
  • String (java.lang)
  • Date (java.sql)
    A class which can consume and produce dates in SQL Date format. Dates are represented in SQL as yyyy
  • ConcurrentHashMap (java.util.concurrent)
    A plug-in replacement for JDK1.5 java.util.concurrent.ConcurrentHashMap. This version is based on or
  • Annotation (javassist.bytecode.annotation)
    The annotation structure.An instance of this class is returned bygetAnnotations() in AnnotationsAttr
  • JLabel (javax.swing)
  • PhpStorm for WordPress
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyStudentsTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now