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

How to turn off 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
  • 44,417
  • 8
  • 90
  • 141
11
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
  • 113
  • 1
  • 4
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
4 answers

How to get the number of lines from a jtextpane

Is there a way of "extracting" the number of lines from a filled with text jtextpane? If there is, does it work if some of the lines are due to text wrapping?
martin
  • 1,007
  • 2
  • 16
  • 32
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
  • 788
  • 6
  • 19
  • 39
9
votes
1 answer

Syntax-Highlighting in JTextPane using SwingWorker

I am trying to do text highlighting in JTextPane. I'm using SwingWorker to do highlighting in background. But i'm unable to get desired output. My Code is as Follow: Main Class: class MultiColor { private static void displayGUI() { final…
Sachin Kumar
  • 781
  • 1
  • 9
  • 28
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,372
  • 2
  • 11
  • 27
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
  • 13,563
  • 35
  • 109
  • 174
8
votes
1 answer

How is word-wrapping implemented in JTextPane, and how do I make it wrap a string without spaces?

How exactly is word-wrapping implemented in JTextPane? I'm trying to understand exactly how it works so that I can modify the behavior. Right now, if I have a standard JTextPane inside a JScrollPane, it will break text at spaces, but not inside long…
A Coder
  • 475
  • 1
  • 6
  • 16
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
  • 5,528
  • 32
  • 60
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
  • 737
  • 2
  • 8
  • 21
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
  • 2
  • 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
  • 302
  • 2
  • 3
  • 8
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
  • 79,475
  • 49
  • 202
  • 273
8
votes
1 answer

Inserting some characters in JTextPane causes performance problems and memory leak

My chat client has a JTextPane in which text is inserted, which can be up to a few lines per second. It usually works fine, even for a longer period of time (e.g. an hour), however sometimes it just gets incredibly slow, using a lot of CPU and…
user2375667
  • 463
  • 3
  • 10
1
2
3
69 70