Put an border in JTextPane

Hi. My plugin adds a toolwindow with a JTextPane in it. How can I put an border in this JTextPane?

The file "style.css" contains this:

.source

But this doesn't work :(

4 comments
Comment actions Permalink

Hello monica,

Sorry, what file "style.css"? IntelliJ IDEA plugins use the Swing user interface
framework, which doesn't use CSS for styling. You can read more about Swing
at http://java.sun.com/docs/books/tutorial/ui/index.html

Hi. My plugin adds a toolwindow with a JTextPane in it. How can I put
an border in this JTextPane?

The file "style.css" contains this:

source {
padding: 12px;
margin: 1em 7px 1em 7px;
border: 2px solid #999999;
font-size: 11px;
overflow: auto;
}
But this doesn't work :(

--
Dmitry Jemerov
Development Lead
JetBrains, Inc.
http://www.jetbrains.com/
"Develop with Pleasure!"


0
Comment actions Permalink

Sorry I am not explained well.
I put Html text in this JTextPane and the Toolwindow show that information like when you open
a file html in browser. But the border doesn't appear. Why, This is not possible?

0
Comment actions Permalink

Don't expect the HTML/CSS styling of Java's HTML renderer to be state of the
art. Maybe you want to set a border to your JTextPane:

textPane.setBorder(new EmptyBorder(10, 20, 30, 40));

0
Comment actions Permalink

From the HTMLEditorKit javadoc:
"The Swing JEditorPane text component supports different kinds of content via a plug-in mechanism called an EditorKit. Because HTML is a very popular format of content, some support is provided by default. The default support is provided by this class, which supports HTML version 3.2 (with some extensions), and is migrating toward version 4.0. The tag is not supported, but some support is provided for the ]]> tag."

If you're using HTML, then as Tom says: don't expect it to be state of the art support. Adding a border directly to your editor component, or its container, would be a lot easier and predictable.

The HTML 3.2 spec is at http://www.w3.org/TR/REC-html32

- Steve

0

Please sign in to leave a comment.