Questions tagged [styleddocument]

`StyledDocument` is a Java interface that extends `Document`. It helps Swing Components like `JTextPane` to render HTML and other markup-language-content.

StyledDocument is a Java interface, extending Document, to help Swing Components like JTextPane that supports the javax.swing.text API to render HTML and other markup-language content. From the JavaDoc it just says:

Interface for a generic styled document.

You normally don't handle with this interface, Methods like JEditorPane.setContentPane() automatically installs the required StyledDocument on your Component.

65 questions
2
votes
1 answer

Add image to JTextPane that overlaps lines to save space

I have a JTextPane with a StyledDocument and need to add an image between text that is higher than the font. This means that normally the line gets higher: What I'm aiming for is to have the image slightly overlap, so it uses less space. In the…
user2375667
  • 463
  • 3
  • 10
2
votes
1 answer

How to write to a StyledDocument with a specific charset?

for a NetBeans plugin I want to change the content of a file (which is opened in the NetBeans editor) with a specific String and a specific charset. In order to achieve that, I open the file (a DataObject) with an EditorCookie and then I change the…
Benny Code
  • 51,456
  • 28
  • 233
  • 198
2
votes
1 answer

JTextField with styled blocks

I need some kind of JTextField that replace carriage return characters by a styled block displaying the text with another font, style or color. By example, the text.. Dear Mr. Smith,\nblablabla...\nRegards... ..would be shown to the…
Béatrice Cassistat
  • 1,048
  • 12
  • 37
1
vote
0 answers

How do I add syntax coloring in my own code editor?

I am building my own code editor in java. How do I add syntax coloring like other code editors in it? I am able to add syntax highlighting like one we can do in Word or Excel (in which highlight background). Here is my function for syntax…
1
vote
2 answers

what is the meaning of boolean argument in StyleConstants.setBold?

I want to set bold the charecters within specific range as Bold. How could I do that? System.out.println("Painting keywords:......."); for(int index =0;index
Muthu Ganapathy Nathan
  • 3,199
  • 16
  • 47
  • 77
1
vote
1 answer

Material UI Paper not taking full width at small view port

I am developing a website where I am using component for dark mode display, but while shrinking below 600px Component getting shrunk way too much and not others. My appjs: function MyApp({ Component, pageProps }) { return ( <> …
Ashish Maurya
  • 59
  • 2
  • 9
1
vote
1 answer

How to save a StyledDocument from textPane into a .doc file?

I don't know if this is even possible, but what I would like to do is to save a Styled Document (user can change text: bold, underline, italic and 3 sizes of font) in a .doc file - so he could open it later on his own with any other text editor that…
Ves
  • 25
  • 7
1
vote
1 answer

How to preserve style of texts in JTextPane while append strings

Hi I have JTextPane and I want to load contents (text with font information) in different time. the appending text will always change in Font name or size or bold or italic. When I inserted new string(with diff fonts), TextPane always loosing font…
Saravanan
  • 67
  • 2
  • 11
1
vote
1 answer

Using DocumentFilter iteratively

I am trying to run this code: How to change the color of specific words in a JTextPane? private final class CustomDocumentFilter extends DocumentFilter { private final StyledDocument styledDocument = yourTextPane.getStyledDocument(); …
Hans
  • 361
  • 1
  • 3
  • 9
1
vote
1 answer

how to get the style from the selected text in JTextpane?

Getting the Bold and Italic Styles From the JTextPane's Selectedtext int start = jTextpane.getSelectionStart(); int end = jTextpane.getSelectionEnd(); String selectedText = jTextpane.getSelectedText(); Applying Style StyledDocument doc =…
Sriram S
  • 533
  • 3
  • 26
1
vote
1 answer

Appending hyperlinks to JEditorPane

I've got a program outputs some URLs to a JEditorPane. I want the URLs to be hyperlinks. The program will basically output the URLS to the JEditorPane as if it were a log. I've got it somewhat working, but it's not hyperlinking the URLs. Here's the…
Andrio
  • 1,852
  • 2
  • 25
  • 54
1
vote
3 answers

JTextPane additional empty lines

I have a JTextPane I set its text with the following method. public void setConfigPaneText(String content, Style style) { StyledDocument logDoc = configPane.getStyledDocument(); if(style == null) { style =…
Bence Kaulics
  • 7,066
  • 7
  • 33
  • 63
1
vote
1 answer

Unable to style JTextPane and display HTML images together

I have been using a JTextPane to display basic HTML content including locally saved images. I have been trying to style the JTextPane using the text pane's input attributes. Whenever I modify the styling of the pane, the HTML images I have break and…
LadyBernkastel
  • 447
  • 4
  • 13
1
vote
1 answer

How to replace a StyledDocument in a JTextPane

I seem to have run into a snag replacing text in a JTextPane. I have a couple of JTextPanes that I need to change the exiting text. I can do this with initial text but when I call to change the document, I see this change in the call but the panel…
jbolt
  • 688
  • 3
  • 16
  • 37
1
vote
1 answer

Removing a part of a StyledDocument First-in-Last-Out and keeping the lay-out

While having quite some free time to use, I ran into a problem concerning a StyledDocument as part of a JTextPane. I want to remove the first part of the text when the total size of the Document reaches value x (10.000 in my case). But since it is…