Questions tagged [jtextpane]

A Java Swing text component that can be marked up with attributes that are represented graphically.

A Java Swing text component that can be marked up with attributes that are represented graphically. You can find how-to information and examples of using text panes in Using Text Components, a section in The Java Tutorial.

1014 questions
35
votes
3 answers

JTextPane appending a new string

In an every article the answer to a question "How to append a string to a JEditorPane?" is something like jep.setText(jep.getText + "new string"); I have tried this: jep.setText("Termination time : " + …
Dmitry
  • 2,878
  • 5
  • 41
  • 63
32
votes
1 answer

Centering Text in a JTextArea or JTextPane - Horizontal Text Alignment

Is there a way to create horizontally centered text for a JTextArea like with a JTextField? setHorizontalAlignment(JTextField.CENTER); Is there a way I can accomplish the same thing with a multi-line text area? I can't find a method for it with…
Awaken
  • 1,193
  • 2
  • 13
  • 26
25
votes
5 answers

How to change the color of specific words in a JTextPane?

How do I change the color of specific words in a JTextPane just while the user is typing? Should I override JTextPane paintComponent method?
Soheil
  • 1,610
  • 6
  • 31
  • 63
17
votes
5 answers

JTextPane highlight text

Can I highlight some text into a JTextPane starting from a value and ending from another value like the following but with the yellow color? "" JTextPane highlight text "" Thanks.
xdevel2000
  • 19,270
  • 35
  • 120
  • 188
16
votes
4 answers

Wrap long words in JTextPane (Java 7)

In all versions of Java up to 6, the default behaviour of a JTextPane put inside a JScrollPane was: wrap lines at word boundaries if possible. If not, then wrap them anyway. In JDK 7, the default behaviour seems to be: wrap lines at word boundaries…
Al-Khwarizmi
  • 453
  • 5
  • 8
16
votes
5 answers

How to have a Scrollable JTextPane?

I would like to have a JTextPane that have scroll bar, how can I do so ? Thanks.
DNB5brims
  • 25,200
  • 45
  • 121
  • 180
15
votes
2 answers

Getting 'Attempt to mutate notification' exception

My goal is to implement blue coloring of keywords written by user into JTextPane. This is how my code look like: private class DocumentHandler implements DocumentListener { @Override public void changedUpdate(DocumentEvent ev) { …
user2102972
  • 231
  • 1
  • 6
  • 12
14
votes
3 answers

Styling text in a JTextArea or JTextPane

Basically, I have a JTextPane to hold some text which I wish to style. JTextArea would have been better for me to use but I'm told you cannot style the text in these? However, the JTextPane doesn't seem to style properly. For example, the following…
mino
  • 6,340
  • 21
  • 55
  • 72
14
votes
3 answers

How to add text different color on JTextPane

Can anybody help me with simple log, I have to add at first line on JTextPane log messages with chosen color ( green ok, red failure ). How to achieve this ?
Almira Bojani
  • 517
  • 2
  • 10
  • 19
13
votes
2 answers

How does one print total number of pages in a JTextPane footer?

I have searched high and low for this answer and have come up blank. I have a requirement to print the contents of a JTextPane with a footer that says "Page of pages". It appears to impossible to do this simple function in Java. I can set…
Banjo
  • 151
  • 4
12
votes
1 answer

Add HTML content to Document associated with JTextPane

I have a question regarding some simple console I'm making. I know that it's possible to add html content to JTextPane with function setText() with previously set setContentType("text/html"); . But for the needs of my application I need to work…
Serhiy
  • 3,846
  • 2
  • 33
  • 62
12
votes
2 answers

JEditorPane with Javascript and CSS support

I am working on Swing using JEditorPane but it's not supporting the Javascript or some advanced tag like etc. and not supporting the color, font style size etc. Is there any solution so that editor pane can display the HTML file as it is…
Adesh singh
  • 1,933
  • 9
  • 21
  • 35
12
votes
2 answers

Monospaced font/symbols for JTextPane

I want to build a console-like output using JTextPane. Therefore I am using a monospaced font: textpane.setFont(new Font(Font.MONOSPACED, Font.PLAIN, 12)); This works fine for all kind of alphanum (like a-z, 0-9 etc.) characters, but when it comes…
user28061
  • 334
  • 1
  • 4
  • 13
11
votes
2 answers

JEditorpane vs. JTextPane

i have to create a project in java swing for my college. An editor of java files with proper text highlighting i.e different colors and fonts for java keywords, java comments and for normal text. Help me to select one of two styled text component…
Sachin Kumar
  • 731
  • 1
  • 9
  • 24
10
votes
3 answers

Java - Change font in a JTextPane containing HTML

I have a JTextPane and I have some text within that JTextPane. However, because I have been using HTML within the Pane, the text seems to have been automatically changed to Times New Roman. I'm trying to set the font type within the JTextPane to…
mino
  • 6,340
  • 21
  • 55
  • 72
1
2 3
67 68