Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JTextField with a DefaultStyledDocument

 
Jared Cope
Ranch Hand
Posts: 243
  • 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
  • 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.
 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic