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

How to set default background color for JTextPane

I've already searched all over the net, and tried several things, to try to set the default background color for JTextPane, but it still shows the default white color. I'm trying to simulate console output, and I need the whole background to be…
user1572522
  • 569
  • 2
  • 11
  • 26
4
votes
2 answers

Java JTextPane Change Font of Selected Text

I have a JTextPane (or JEditorPane, I can use either no problem). How can I change the font of a selected area to a specific font? textpane.getSelectedText().setFont() won't work. (Even with font-family)
Sev
  • 15,401
  • 9
  • 56
  • 75
4
votes
4 answers

Changing the background color of a paragraph in JTextPane (Java Swing)

Is it possible to change the background color of a paragraph in Java Swing? I tried to set it using the setParagraphAttributes method (code below) but doesn't seem to work. StyledDocument doc = textPanel.getStyledDocument(); Style style =…
Sudar
  • 18,954
  • 30
  • 85
  • 131
4
votes
3 answers

copy jTextPane text to clipboard

I have a form which contains a jTextPane and a jButton, I've set the jTextPane Accessible Description to text/html, now I want when I click on the jButton to copy the content of the jTextPane to my clipboard, I tried this code : private void…
Croviajo
  • 253
  • 1
  • 8
  • 17
4
votes
1 answer

Java - Auto-Indentation in JTextPane

I'm making a text-editor in Java, and I have everything I need but auto-indent. How would I make the indentation stay the same if they go to a new line. I'm using a JTextPane for my editor window. Basically, if a user enters a new line, I want the…
user2228462
  • 589
  • 1
  • 5
  • 14
4
votes
1 answer

How to make JScrollPane/JTextPane "Intelligent"

So, i have a situation where, a scrollbar needs to scroll automatically when meets a certain logical situation. In my case, i have few lines written on JTextPane, and i am highlighting the words.So, when the point is reached,where the text is not…
joey rohan
  • 3,505
  • 5
  • 33
  • 70
4
votes
2 answers

Alloy Look and Feel and Anti-Aliasing

Anyone here using the Alloy Look and Feel? I'm facing a strange bug with anti-aliasing and JTextComponents. Alloy by default does not use anti-aliasing at all, so I have to force it by creating my own UI-classes. This works fine in most cases, but…
n00bster
  • 2,525
  • 2
  • 16
  • 15
4
votes
3 answers

Change specific String attributes in StyledDocument

I am trying to create a text editor. I am using a JTextPane with a StyledDocument. What I am trying to implement is a way to change the attributes of selected text. This works in the following way : the user inputs the desired text. Afterwards, he…
4
votes
3 answers

How to center text and a JComponent in a JTextPane vertically?

Currently it looks so What to do so that it looks so? Below is my code: JFrame f = new JFrame(); JTextPane textPane = new JTextPane(); JTextField component = new JTextField(" "); …
ka3ak
  • 2,435
  • 2
  • 30
  • 57
4
votes
1 answer

Remove default padding in JTextPane on Windows

For displaying information on a Java Swing GUI I use a mixture of JLabel components and JTextPanes. As you can see in the following image, all labels are JLabels except for the one in the bottom right corner which is marked red and yellow. This…
ToFi
  • 1,167
  • 17
  • 29
4
votes
2 answers

Change Text Cursor Size in JTextPane

I'm making a simple text editor, and I have a JTextPane and changed the spacing to 1.5f. The only problem is that the "Text Cursor" spans all the pixels from the current line to the next one, regardless of font size. Here's an example: Is there…
Peter Mauldin
  • 55
  • 1
  • 6
4
votes
3 answers

JTextPane - dynamic word wrap

I tried to use jTextPane1.setText("xxx xxxx xxx xxxxx xx xxx xxxx xxx etc..."); but JTextPane does not word wrap it at all showing all the text in one line only instead. It would be interesting to support word wrap on jTextPane1 resized too... So my…
user592704
  • 3,674
  • 11
  • 70
  • 107
4
votes
2 answers

Make JTextPane adjust height to content

I'm trying to get a JTextPane to adjust its height according to whatever content I feed it. All I can do is to set a fixed height in pixels using Dimension. How do I make the JTextPane collapse/expand so it will fit to contents? I might add that I…
fiskeben
  • 3,395
  • 4
  • 31
  • 35
4
votes
2 answers

How to view paragraph symbol in JTextPane using Java Code?

How can I view a pilcrow, ¶, in a JTextPane using Java? Please adivise me or send me any sample code.
Rishi
  • 95
  • 2
  • 9
4
votes
3 answers

Method that returns the line number for a given JTextPane position?

I'm looking for a method that computes the line number of a given text position in a JTextPane with wrapping enabled. Example: This a very very very very very very very very very very very very very very very very very very very very very very long…
Marlo Guthrie
  • 2,649
  • 4
  • 25
  • 20