A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Swing / AWT / SWT
JTextField with a DefaultStyledDocument
Joined: Aug 18, 2004
Jun 02, 2005 04:33:00
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?
SCJP 1.4 91%, SCJP 1.5 88%, SCJD B&S
Joined: Jan 14, 2004
Jun 02, 2005 09:39:00
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:
subject: JTextField with a DefaultStyledDocument
JTABLE + JTEXTFIELD....
To change the color of a few characters in a JTextArea - urgent
Convert DefaultStyledDocument to HTMLDocument
retrieve the data from JTextField
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2014