File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JTextField with a DefaultStyledDocument

 
Jared Cope
Ranch Hand
Posts: 243
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I want to use a default styled document with a JTextField in order to implement a spellchecker and make incorrect words turn red.

I have this working on a JTextPane, but for some reason I can not get the red style to work with a JTextField.

It is like the fancy styles are getting ignored by the JTextField even though I have explicitly set it to use a DefaultStyledDocument as the data model.

Does anyone have any suggestions?

Cheers, Jared.
 
Craig Wood
Ranch Hand
Posts: 1535
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JTextField does not support styled content. The 'setDocument' method is used mainly for extensions of PlainDocument designed for input constraint (like the newer DocumentFilter) as shown in the api. JTextPane is the minimum choice for text styling.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic