File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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 Android Security Essentials Live Lessons this week in the Android 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
retrieve the data from JTextField
Convert DefaultStyledDocument to HTMLDocument
JTABLE + JTEXTFIELD....
DefaultStyledDocument??
To change the color of a few characters in a JTextArea - urgent