This week's book giveaway is in the General Computing forum.
We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes JTextField with a DefaultStyledDocument Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » Swing / AWT / SWT
Reply Bookmark "JTextField with a DefaultStyledDocument" Watch "JTextField with a DefaultStyledDocument" New topic
Author

JTextField with a DefaultStyledDocument

Jared Cope
Ranch Hand

Joined: Aug 18, 2004
Posts: 243
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.


SCJP 1.4 91%, SCJP 1.5 88%, SCJD B&S
Craig Wood
Ranch Hand

Joined: Jan 14, 2004
Posts: 1535
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JTextField with a DefaultStyledDocument
 
Similar Threads
DefaultStyledDocument??
JTABLE + JTEXTFIELD....
retrieve the data from JTextField
Convert DefaultStyledDocument to HTMLDocument
To change the color of a few characters in a JTextArea - urgent