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

How to output JTextPane styled contents to HTML, including custom style?

I currently use a JTextPane to allow users to add/edit text. It allows bold/italic/underline (and I plan to allow links in the future). It also allows users to drop buttons in, which are inserted as custom styles. The panel looks like: < < image…
Michael Robinson
  • 29,278
  • 12
  • 104
  • 130
6
votes
4 answers

JTextPane prevents scrolling in the parent JScrollPane

I have the following "tree" of objects: JPanel JScrollPane JPanel JPanel JScrollPane JTextPane When using the mouse wheel to scroll over the outer JScrollPane I encounter one annoying…
exhuma
  • 20,071
  • 12
  • 90
  • 123
6
votes
1 answer

JTextPane text background color does not work

I am trying to make a small HTML-wysiwyg with a JTextPane but I can't get the BackgroundAction to work. I am using setCharacterAttributes on the StyledDocument of the JTextPane but it seems problematic. The view is ok but the Document is not. Here…
Guillaume Polet
  • 47,259
  • 4
  • 83
  • 117
5
votes
1 answer

Line numbers in jtextpane in Netbeans

I am using Netbeans 7.1. are there any option for displaying line numbers in jtextpane?
user1162286
  • 81
  • 1
  • 7
5
votes
1 answer

Java HTMLDocument (insertAfterEnd, insertAfterStart, insertBeforeEnd, insertBeforeStart) not working?

I have a JEditorPane that displays HTML that is generated programmatically (at runtime). Up to now when I was adding a "line" I was re-creating the whole HTML text in a string buffer and then passing it to JEditorPane.setText method. Now the HTML…
HpTerm
  • 8,151
  • 12
  • 51
  • 67
5
votes
1 answer

Which listener can know that the JTextPane value is changed?

I would like to know when JTextPane content is changed. I implemented a keyboard listener, but it is only detecting keyboard events. If the user pastes text via mouse or drag the text inside, then I am not enable to detect the JTextPane value is…
DNB5brims
  • 29,344
  • 50
  • 131
  • 195
5
votes
1 answer

Enabling word wrap in a JTextPane with HTMLDocument

Everywhere I read answers of people finding ways of enabling word wrapping in a JTextPane, but none of them work for me. I'm using an HTMLDocument (to display "text/html" content) and nothing that I have found so far got it to work. The JTextPane …
Yanick Rochon
  • 51,409
  • 25
  • 133
  • 214
5
votes
3 answers

Deselect selected text in JTextPane

I have an editor in which I want to check that selected text will not contain some words. If it contains those particular words, then I need to deselect the selection made by user. Is there any way to do that in JTextPane?
charmi
  • 197
  • 3
  • 17
5
votes
1 answer

JTextPane immutable text blocks

I've been creating something like text editor for a while and noticed one interesting feature in NetBeans: when creating Java Application from a template (for example, "Desktop Application"), it creates immutable blocks of code (they are present for…
shybovycha
  • 11,556
  • 6
  • 52
  • 82
5
votes
1 answer

How does one properly initialize a JTextPane StyleSheet, so no other HTML enabled component is affected by the style?

I'm trying to use a JTextPane to render some HTML and apply a CSS stylesheet to it. This means I'm using HTMLEditorKit and StyleSheet classes. I know that all HTMLEditorKits share the same default StyleSheet instance, so if you change this default…
predi
  • 5,528
  • 32
  • 60
5
votes
2 answers

colored xml display in swing

Is there an "easy" way to display xml data to a user via an JEditorPane or JTextPane in colored/highlighted way?
Cratylus
  • 52,998
  • 69
  • 209
  • 339
5
votes
2 answers

How to set fixed width but dynamic height on JTextPane?

I want to use a JTextpane with fixed width but dynamic height which should also allow wrapping. The height should change as the user adds or removes text. I would've used a JTextArea but the text has to be styled differently. Is there an easy way to…
user5809481
5
votes
1 answer

Undo And Redo In JTextPane Ignoring Style Changes

I was wondering if there is a way to ignore the text style changes in a JTextPane while using Swing's UndoManager?
5
votes
2 answers

How to make a checkbox with an hyperlink

Question : I'm try to create an check-box in Java that contains in the text an hyper-link. But, I couldn't make the link clickable, and only the link, not the whole text. Here my sample code : public class TestClickLinkInCheckBox implements…
MonkeyJLuffy
  • 195
  • 3
  • 15
5
votes
2 answers

Aligning and Inlining components (or icons) in JTextPane

I'm working on an application in Java which, among other things, is supposed to display the details of a Magic: The Gathering card in a text field (since I'm using Swing, this is currently a JTextPane). Those details contain text and small icons,…
Blacklands
  • 65
  • 1
  • 2
  • 6