This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach 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 | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
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
JTABLE + JTEXTFIELD....
Convert DefaultStyledDocument to HTMLDocument
DefaultStyledDocument??
To change the color of a few characters in a JTextArea - urgent
retrieve the data from JTextField