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
0
votes
1 answer

How to persistently store styled text from a Document in a database?

So I'm currently working on a program that allows users to created "posts" with styled text. Right now I'm using Java's DefaultStyledDocument, but I'm open to other options (preferably they implement StyledDocument, though). I originally posted…
DonyorM
  • 1,760
  • 1
  • 20
  • 34
0
votes
1 answer

How to get the content with all attributes of a JTextPane?

I have a JTextPane and on a ActionEvent, I want to save the content of the JTextPane (with the colors, text and other attributes) in another class (as a variable). Later on I want to exchange the content of the JTextPane with the one of the…
user3549340
  • 121
  • 2
  • 2
  • 7
0
votes
1 answer

Splitting StyledDocument

I am currently writing a program that accepts styled text in a JTextPane and also displays the same styled text in a non-editable JTextPane. The problem is that I actually want to parse the documents between inputting and displaying. Basically I…
DonyorM
  • 1,760
  • 1
  • 20
  • 34
0
votes
0 answers

Fix style of DefaultStyledDocument

I am wondering if it is possible to fix the style of StyledDocument in java. According to my observation, the style will change depending on style of previous position. So I can key in the content with my defined style without being affected by the…
johnklee
  • 2,140
  • 2
  • 18
  • 27
0
votes
1 answer

Is it possible to set length of paragraph in JTextPane StyledDocument?

I am using JTextPane with StyledDocument, is it possible to set length of its paragraph? My goal is when the length of text which is inserted in the JTextPane is longer than 400px, exceed go to new line. Edit: I use method below to set style for…
user90
  • 73
  • 3
  • 13
0
votes
1 answer

Java styleddocument change attribute for next input

I have JTextPane and a checkbox representing lets say bold font. So if checkbox is checked, I want whatever I type in JTextPane to be bold. I do not want to change whole font for JTextPane , I just want to set next char to be bold. I made this, and…
JollyRoger
  • 19
  • 1
  • 1
  • 4
0
votes
2 answers

How can my JTextPane display multiple fonts?

I'm trying to design a part of a bigger GUI that will format some text to look good. It should be able to play with text in a lot of funny ways. Adding borders, underlining, i.e anything I could want to do with text for decorative purposes. Is…
user2651804
  • 1,464
  • 4
  • 22
  • 45
0
votes
1 answer

How to use onmouseover in StyledDocumend assosiated with a JTextPane

I want to highlight different sections of text when mouse is hovered over them. I'm currently using styleddocument with jTextPane. Can somebody please help me in defining style so that individual strings/paragraphs can be highlighted when mouseover…
Red Devil
  • 349
  • 4
  • 16
0
votes
1 answer

How do I put StyledDocuments together in Java?

I want to make a StyledDocument from 2 other StyledDocuments in Java. Is there a possibility of doing this?
0
votes
1 answer

Detecting Styled Text in a Document

I have a JTextPane for users to write journal entries which they can style by selecting text and choosing a menu item such as bold or italic etc. These items are connected to one of the Styled Editor kits (eg StyledEditorKit.BoldAction() ). Is…
0
votes
2 answers

How to get StyledDocument.insertString() to update better

I have a background Thread that gets text data from an InputStream and tries to insert it into a JTextPane: iLen = doc.getLength(); doc.insertString(iLen, lineS, normalStyle); if ( iLen > 0 ) textPane.setCaretPosition(doc.getLength() -…
user1572522
  • 569
  • 2
  • 11
  • 26
0
votes
1 answer

How to set a global style for styled document in java swing

I have a StyledDocument to which I am adding some style. I want to have some default (global) style that works for all the styles I create. For example a global background for all the style, so that I don't have to specify the background for each…
me_digvijay
  • 5,374
  • 9
  • 46
  • 83
0
votes
0 answers

StyledDocument or RTF document to PDF conversion

how can I get a StyledDocument directly or over the RTFEditorKit to a PDF file? Currently I have a RTF document and converted this file with Aspose.Word to PDF, but I don't want to spend so much money for this library. I want to have a solution…
marc3l
  • 2,525
  • 7
  • 34
  • 62
0
votes
1 answer

ColorPane - grab strings of different character possible?

I'm currently working on a old project that was given to me, it currently use java swing and has a basic gui. It has a ColorPane that extends Jtextpane to change colors of selected text. It uses this methond public void changeSelectedColor(Color…
Thao Nguyen
  • 901
  • 7
  • 22
  • 42
0
votes
2 answers

StyledDocument adding extra count to indexof for each line of file

I have a strange problem (at least it appears that way) that when searching for a string in a textPane, I get an extra index for each line number that is searched and returned when using StyledDoc verses just getting the text from a textPane. I get…
jbolt
  • 688
  • 3
  • 16
  • 37