Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

JTextPane setFont doesnt work

807588Aug 29 2006 — edited Mar 26 2009
Hi All

I have set the font of a jtextpane by using the following code:

this.text = new JTextPane( new DefaultStyledDocument() );
this.text.setBorder( new EmptyBorder( 0, 0, 0, 0 ) );
this.text.setText( "" );
this.text.setSize( 600, 300 );
this.text.setFont( new Font( "Monospaced", Font.PLAIN, 10 ));

I need to set the font to Monospaced to ensure all the characters are equally spaced. Whatever I do nothing and I mean nothing works. I have tried other font types and they dont work.

It seams like a bug but I could be doing something wrong.

Can anybody help me find a solution.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 23 2009
Added on Aug 29 2006
7 comments
1,522 views