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
10
votes
2 answers

JTextPane line wrapping

Unlike JTextArea, JTextPane has no option to turn line wrapping off. I found one solution to turning off line wrapping in JTextPanes, but it seems too verbose for such a simple problem. Is there a better way to do this?
Jeffrey
  • 42,428
  • 7
  • 84
  • 138
10
votes
4 answers

Adding tooltips to JTextPane

I want to add some tooltips to only a certain text inside a JTextPane. As an example, if there is a reference link text inside the JTextPane I want to add a tooltip to that text to show the link. Is there any way I can achieve this functionality?
Nuwan
  • 360
  • 3
  • 8
  • 20
10
votes
3 answers

Highlight current row in JTextPane

I'm trying for more than 2 days to implement a specific requirement for a text editor window... unfortunately without success so far :( The goal is to get a text editor window which will highlight the current row, like other text editors do. With…
Preachie
  • 103
  • 1
  • 4
9
votes
3 answers

Java: Register key press on JTextPane

I'm making an application with java that has a JTextPane. I want to be able to execute some code when the enter key is pressed (or when the user goes to the next line). I've looked on the web and not found a solution. Would it be better to tackle…
Mohammad Adib
  • 758
  • 5
  • 18
  • 38
9
votes
3 answers

How can I set each character to a different color/background color in a JTextPane?

I've been searching for this for a while and so far all I've been able to come up with is how to create a style and apply it to a character like so: StyledDocument doc = (StyledDocument) new DefaultStyledDocument(); JTextPane textpane = new…
JaredL
  • 1,213
  • 2
  • 10
  • 24
9
votes
1 answer

JTextPane/JEditorPane and weird text issue

I am creating a simple chat program that I want to eventually show html links. My problem right now is that I can't get the text to appear next to the users name as I want it to. I want the user's name to be bold, and the text to appear right next…
mainstringargs
  • 11,482
  • 33
  • 101
  • 163
8
votes
1 answer

How do I use javax.swing.text.AsyncBoxView to delegate text layout in JTextPane to a non-EDT thread?

I've hit the performance limits of JTextPane, while trying to implement a console style component. For the most part, my console behaves quite well, but attempts to spam it with large amounts of non- space separated text end up freezing the GUI…
predi
  • 4,823
  • 26
  • 52
8
votes
5 answers

1 pixel table border in JTextPane using HTML

I'm using a JTextPane to display some HTML that contains a table with a border. I want it to have a simple 1 pixel border. I tried using style="border: 1px solid; border-collapse:collapse". This works in a web browser, but not in JTextPane. Is there…
Chris B
  • 727
  • 1
  • 8
  • 20
8
votes
1 answer

JTextPane Background Color

I am making a text-based game where the user inputs text to solve the game. I decided to use java swing to display the text, and I want to have the background of the textPane to be black. I have tried everything I have found (commented out), but non…
Slushy_G
  • 137
  • 1
  • 9
8
votes
2 answers

Resize dialog message (JOptionPane) for long sentence with fixed width

I'm trying to resize the height of the dialog box (JOptionPane) for long sentence with hyperlink. My code is .. public class DialogTest { public static void main(String[] args) throws Exception { JTextPane jtp = new JTextPane(); Document doc…
swordartist
  • 272
  • 2
  • 3
  • 7
8
votes
4 answers

Getting raw text from JTextPane

In my application, I use a JTextPane to display some log information. As I want to hightlight some specific lines in this text (for example the error messages), I set the contentType as "text/html". This way, I can format my text. Now, I create a…
Romain Linsolas
  • 73,921
  • 45
  • 197
  • 265
8
votes
5 answers

Clickable text in a JTextPane

I have a JTextPane declared like the following: JTextPane box = new JTextPane(); JScrollPane scroll = new JScrollPane(); StyledDocument doc = box.getStyledDocument(); scroll.setViewportView(box); scroll = new JScrollPane(box); And I am appending…
Joe
  • 755
  • 1
  • 8
  • 20
8
votes
3 answers

setContentType("text/html") for JTextPane doesn't work as it is expected

When you setContentType("text/html") it is applied only for the text that is set via JTextPane.setText(). All other text, that is put to the JTextPane via styles is "immune" to content type. Here is what I mean: private final String[] messages =…
Dragon
  • 2,379
  • 10
  • 40
  • 61
7
votes
1 answer

Why is Document.insertString()'s runtime not constant-time?

I am working on creating a logger to show output as part of a larger Java swing GUI. Unfortunately I was experiencing a slowdown after adding it. I have traced the problem to repeated calls of Document.insertString(). I made a test which shows this…
code11
  • 1,721
  • 5
  • 25
  • 33
7
votes
2 answers

Coordinates of a JTextPane to make a Screenshot in Java

I hope some one can help me, this is what I want to do. I have a JTextPane and I want to take a screenshot to that specific JTextPane coordinates and size, so far I can do a screenshot with the size of the JTextPane but I can't get the specific…
1
2
3
67 68