Questions tagged [defaultstyleddocument]
17 questions
7
votes
2 answers
Java GUI: Document Object Model
HTML has a Document Object Model, which Javascript can then manipulate / move around.
When I create GUIs in Swing -- the model appears to be very difference (I don't know the name of the model), since I'm creating layout managers, and sticking…

user1383359
- 2,673
- 2
- 25
- 32
3
votes
1 answer
JEditorPane - switching back to the default editor kit
If you change the editor kit of a JEditorPane to HTMLEditorKit, how do you change it back to the default (plain text) editor kit, like how it is when you first instantiate one? I want it to do this so that I can load all of the html and display it…

Jutanium
- 421
- 3
- 16
2
votes
1 answer
How to change default strong blue color in HTML form controls in Chrome?
Is there any workaround except using 3 rd css libraries to change default sharp blue styling of input elements? After such update the look of complicated interfaces happened to be completely inconsistent...

Alex Khimich
- 788
- 9
- 10
1
vote
1 answer
How to clear all the styles in JTextPane?
I am creating a simple .rtf file editor application using RTFEditorKit(). I have added code to create a new document, open an .rtf document, save as an .rtf document, and to add styles to the content of the document such as bold, italics and…

AbiSaran
- 2,538
- 3
- 9
- 15
1
vote
3 answers
Java code optimization - how can I optimize this remove() function?
I am making a custom language as a project for a class called Compilers. The whole project is in Java, using JFlex as my lexical analyzer, and Cup as my syntactic analyzer.
I created a simple text editor for the language, which basically consists of…

Wilmer Carranza
- 13
- 2
- 4
1
vote
1 answer
Insert one DefaultStyledDocument into another DefaultStyledDocument
I want to insert one DefaultStyledDocument into another DefaultStyledDocument. How do I do this? I know of this method:
AbstractDocument.insertString(int offs,
String str,
AttributeSet a)
What I…

Paul Reiners
- 8,576
- 33
- 117
- 202
1
vote
1 answer
Inserting a LeafElement myself
I am trying to insert a LeafElement inside an overriden DefaultStyledDocument (also providing a custom EditorKit) for a JEditorPane : but I get a javax.swing.text.StateInvariantError.
So following the guidelness of a JGuru forum topic, I added…

loloof64
- 5,252
- 12
- 41
- 78
1
vote
1 answer
How can I know the number of inserted characters by Document.insertString() method?
I am making my custom implementation of DefaultStyledDocument. And sometimes, I need to know how many characters will be (or has been) inserted by the Document.insertString() method.
But I did not find how to compute it. (The method insertString()…

loloof64
- 5,252
- 12
- 41
- 78
1
vote
1 answer
How can I copy/paste styled text from/to clipboard?
I have I JTextPane and I'm using DefaultStyledDocument as a text model. I currenly use the JTextPane's default copy() and paste() methods for copying and pasting, but as you know they copy/paste plain text only. I need to be able to copy styled text…

Igor
- 1,532
- 4
- 23
- 44
1
vote
1 answer
Setting font color on DefaultStyledDocument
I know that I can set the font size on a javax.swing.text.DefaultStyledDocument like this:
public void apply(DefaultStyledDocument document) {
final MutableAttributeSet attributeSet = new SimpleAttributeSet();
…

Paul Reiners
- 8,576
- 33
- 117
- 202
0
votes
1 answer
Java syntax highlighting mismatched char
I'm implementing a syntax highlighting by reusing the code posted here. The problem is that each char "{,},<,>" is not coloured it is not followed by a non-char. For example in "
@Override
public void insertString (int offset, String str,…

Discipulos
- 423
- 8
- 23
0
votes
1 answer
Jython - how can I merge two LeafElements in a DefaultStyledDocument?
I'm trying to "normalise" a DefaultStyledDocument subclass, in the sense that we have org.w3c.dom.Node.normalize(): that is, merge adjoining text "leaves". In the case of a DefaultStyledDocument these leaves are identified for merging if two…

mike rodent
- 14,126
- 11
- 103
- 157
0
votes
2 answers
DefaultStyledDocument.styleChanged(Style style) may not run in a timely manner?
I'm experiencing an intermittent problem with a class that extends javax.swing.text.DefaultStyledDocument. This document is being sent to a printer. Most of the time the formatting of the document looks correct, but once in a while it doesn't. It…

Paul Reiners
- 8,576
- 33
- 117
- 202
0
votes
1 answer
Adding multiple StyleConstants to an AttributeSet
I have a string of text: "This is a || mountain to || on."
I want || and || to appear red, italic, FontSize 9.
I've set individual AttributeSets
StyleContext myProtected = StyleContext.getDefaultStyleContext();
AttributeSet…

Jedi Grunge
- 27
- 7
0
votes
1 answer
JTextPane DefaultStyledDocument and setEditorKit conflict
I'm using JTextPane in a project where I'm supposed to display row numbers and color some keywords. For displaying row numbers, I'm using 'setEditorKit' and for coloring the text, I'm overriding insertString() and removeString() methods of…

mundomug
- 132
- 2
- 11