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
1 answer

How to prevent memory leak in JTextPane.setCaretPosition(int)?

I'm working on a Java application with Swing-based GUI. The application uses JTextPane to output log messages as follows: 1) truncate existing text to keep total text size under the limit; 2) append new text; 3) scroll to the end (actual logic is…
Andrey
  • 2,503
  • 3
  • 30
  • 39
5
votes
2 answers

JTextPane + JScrollPane + word wrap?

Based on existing solutions, I haven't found a way to make a JTextPane (or JEditorPane) have either word-wrap or forced line-wrap inside a JScrollPane. JTextArea is not a solution as I need HTML to display in the particular input. output = new…
CosmoConsole
  • 81
  • 1
  • 5
5
votes
2 answers

How to disable WordWrap in Java JTextPane?

My program has a problem.. It is WordWrap is abled... Exactly, I want to use linwrap but i don't want wordwrap... I searched this JTextPane textPane = new JTextPane(); JPanel noWrapPanel = new JPanel( new BorderLayout() ); noWrapPanel.add( textPane…
user3548003
  • 53
  • 1
  • 3
5
votes
2 answers

JTextPane Synchronize Style Selection UI Problem

I am developing a simple WYSIWYG RTF editor in Java and have a small issue. I need to be able to synchronize the style selection toggle buttons (such as bold, italic, underlined) to the users text selection. For example, if the current text…
S73417H
  • 2,661
  • 3
  • 23
  • 37
5
votes
2 answers

Adding a JButton to a JTextPane

I'm having problems trying to add a JButton to a JTextPane with a String. So what I am trying to do is to add each String in a for loop and then add ad JButton after that added String. The code below is what I am trying to accomplish.…
Douglas Grealis
  • 599
  • 2
  • 11
  • 25
5
votes
2 answers

Get a component from a JTextPane through javax.swing.text.Element?

I am using a JTextPane to display characters and symbols, where the latter are represented by custom painted JComponents. For example, the text pane might show something like this: The text pane is user editable and it is allowed for the user to…
AplusKminus
  • 1,542
  • 1
  • 19
  • 32
5
votes
1 answer

How can I create Log4j 2 appender connected with jTextPane?

I'm currently trying to make Log4j 2 log into a JTextPane. It should act like a STDERR or STDOUT in Netbeans IDE console (incl. text style - color). I know that I need to create an appender and connect it with JTextPane, however I don't know how do…
marty
  • 55
  • 1
  • 6
5
votes
1 answer

Changing the size of JTextPane

I am new in Java, and I just found this piece of code in StackOverflow: ResizeTextArea. I want to use JTextPane instead of JTextArea. In JTextPane, there is no setRows() method to change the number of the lines. Any help would be appreciated.
user2049371
  • 189
  • 1
  • 2
  • 16
5
votes
3 answers

JTextPane/JTextField strange behaviour with rare characters

I've discovered a strange bug in JTextPane/JTextField (or somewhere in the font rendering underneath them). I wonder if anyone else has encountered the same and might have a solution for this. I'm trying to display some "special" or rare characters…
n00bster
  • 2,525
  • 2
  • 16
  • 15
5
votes
4 answers

Disable editing in a JTextPane while allowing visible cursor movement

I have a JTextPane which is populated by reading from a file, after which the data is parsed and formatted. The user is not allowed to edit the JTextPane, but I want them to be able to navigate in it with a visible cursor. If I use…
Gigatron
  • 1,995
  • 6
  • 20
  • 27
5
votes
2 answers

Adding mouselistener to JLabel/JButton inserted in JTextPane

I have a problem where when I try and add a mouselistener to a JLabel or JButton in a JTextPane I get the error "cannot be converted to Mouselistener by invocation conversion". I would prefer to have the component in a JEditorPane. I also heard a…
Confident
  • 321
  • 4
  • 17
5
votes
1 answer

How to wrap text around components in a JTextPane?

I don't understand the wrapping behavior in a JTextPane. If I insert a short text, then a JComponent and then again the short text I can see the inserted stuff in one line if the frame is large enough of course. But if the text is much longer so…
ka3ak
  • 2,435
  • 2
  • 30
  • 57
5
votes
3 answers

How do I set different colors for text and underline in JTextPane?

Just been trying to color the text in JTextPane - but the issue is cannot have different colors for text and the underline. How should I do that or is that even possible? The example below prints all the text and underline in RED. JTextPane pane =…
Sid Malani
  • 2,078
  • 1
  • 13
  • 13
5
votes
2 answers

How do I read a HTML String into a JEditorPane/JTextPane?

Pretty self explanatory, I have a string that is HTML, how do i draw this onto a JEditorPane/JTextPane?
Primm
  • 1,347
  • 4
  • 19
  • 32
5
votes
1 answer

JTextPane - get start position of a displayed line

I've a JTextPane that is used to show a text file. The text appears as follows Line 1 Line 2 Line 3 What I want to get is the start index of the line where my caret is currently positioned. Is there a simple method in JTextPane that can help me…
Sujay
  • 6,753
  • 2
  • 30
  • 49