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.

1037 questions
5
votes
2 answers

JTextPane doesn't display JScrollPane and doesn't Wrap Text

I need to display links so I'm using JTextPane with setContentType. However, the content doesn't wrap and there's no scroll. The content of JTextPane will be returned from a RSS feed. Here's the full code: import java.awt.*; import…
Lily S
  • 245
  • 1
  • 8
  • 18
4
votes
2 answers

How to add images in JTextPane?

I want to give the user the facility to copy and paste Images in JTextPane. Please help me.
Suhail Ahamed
  • 136
  • 1
  • 2
  • 7
4
votes
1 answer

JTextPane preferred size with fixed width

I have a question on how I could easily compute the preferred size/height of a JTextPane given a fixed width. What I have done so far is put my JTextPane in a JScrollPane and whenever I update the text, I update the size of the JScrollPane. Now,…
Guillaume Polet
  • 47,259
  • 4
  • 83
  • 117
4
votes
1 answer

Get the text content of individual Elements from an HTMLDocument

I have a jTextPane that has HTMLEditorKit set as the default editorKit. Calling getDocument on the jTextPane returns an HTMLDocument. I can traverse through this Document, navigating around the elements, but I can't seem to find a way to actually…
Corey Farwell
  • 1,856
  • 3
  • 14
  • 19
4
votes
4 answers

How do I limit the amount of characters in JTextPane as the user types (Java)

I need to not allow any characters to be entered after X have been typed. I need to send a beep after X characters have been typed. I know how to do this after the user presses enter, but I need to do it before the user presses enter. The…
Boundless
  • 2,444
  • 2
  • 25
  • 40
4
votes
1 answer

Displaying urdu characters in JTextPane

How can I display a single Urdu character in a JTextPane? I have translated English characters to Urdu characters. But I can't find any way to correctly display those characters into my text component. My goal is to: Get the key pressed on the…
Muhammad Salman Farooq
  • 1,325
  • 9
  • 26
  • 54
4
votes
2 answers

How to use tag in JTextPane

I have a JTextPane which displays a link to which on click should open a page in the browser. The link is set as a text to the TextPane as shown: Read more.. Also below shows how the link looks like…
Bitmap
  • 12,402
  • 16
  • 64
  • 91
4
votes
2 answers

Font of a StyledDocument associated with a JTextPane

What font does the StyledDocument associated with a JTextPane use? By default, does it use the same font as the JTextPane? In particular, I'm wondering about the font size.
Paul Reiners
  • 8,576
  • 33
  • 117
  • 202
4
votes
2 answers

Swing component flickering when updated a lot

I've got a couple thousand lines of code somewhere and I've noticed that my JTextPane flickers when I update it too much.. I wrote a simplified version here: import java.awt.*; import javax.swing.*; public class Test { static JFrame f; …
Bai Li
  • 1,108
  • 1
  • 16
  • 25
4
votes
3 answers

Part 2 - How do I get consistent rendering when scaling a JTextPane?

I submitted another version of this question and a sample program before: How do I get consistent rendering when scaling a JTextPane? Recapitulating the problem: I would like to allow users to zoom into or out of a non-editable JTextPane. Running…
jht
  • 125
  • 5
4
votes
2 answers

How to show multiple carets in a JTextArea or JTextPane

I want to use a JTextArea or JTextPane as a code change player, and the code changes and caret movements are recorded in a text file. But the problem is, it's recorded from an editor which supports multi selection, so there are more than one caret…
Freewind
  • 193,756
  • 157
  • 432
  • 708
4
votes
1 answer

JTextPane double carriage return

I am using a JTextPane object, let's say its name is jtp, so I can show parts of a somewhat short String in italic or bold. I have a String, let's name it otxt that has a newline. Given I am using Windows it means \r\n and it is created…
4
votes
1 answer

Very slow performance when highlighting words in a JtextPane

In a JTextPane the performance of highlighting a text with ~50000 lines is very slow. Do I have any chance to increase the preformance? Here is a SSCE import java.awt.*; import java.awt.event.*; import javax.swing.*; import…
Ramses
  • 652
  • 2
  • 8
  • 30
4
votes
1 answer

Unexpected padding to the left of first letter/unexpected typographic behaviour in JTextPane

I've implemented a multiline label by extending a JTextPane. The constructor sets various properties to make it look like a label, including disabling any border/setting margins to 0 which works well. Environment: using…
bfour
  • 160
  • 11
4
votes
2 answers

(Java Swing) How do I create a JTextPane with multiple icons on the same line?

As the question states, how do I successfully place multiple icons on the same line of text in a JTextPane? Every time I try to change the value of actionText, the results are very unpredictable. As an example, this is the kind of thing I'm trying…
Billy M.
  • 369
  • 2
  • 16