
Example 3−3: Using JTable and TableModel (continued)
case 0: return filenames[row];
case 1: return new Long(f.length());
case 2: return new Date(f.lastModified());
case 3: return f.isDirectory() ? Boolean.TRUE : Boolean.FALSE;
case 4: return f.canRead() ? Boolean.TRUE : Boolean.FALSE;
case 5: return f.canWrite() ? Boolean.TRUE : Boolean.FALSE;
default: return null;
}
}
}
JTextComponent and HTML Text Display
The most complex component in all of Swing is the JTextComponent, which is a
power ful editor. It is part of the
javax.swing.text package and generally is not
used directly. Instead, you typically use one of its subclasses, such as
JTextField,
JPasswordField, JTextArea,orJEditorPane. The first three of these components
ar e straightforward. They are for the entry of a single line of text, secret text such
as a password, and simple, unformatted, multiline text, respectively.
It is the
JEditorPane component that really makes use of the full power of
JTextComponent. JEditorPane supports the display and editing of complex format-
ted text. In conjunction with the classes in the
javax.swing.text.html and
javax.swing.text.rtf packages, JEditorPane can display and edit HTML and
RTF documents. The ability to display formatted text so easily is a very powerful
featur e. For example, the ability to display HTML documents makes it simple for a
Swing application to add online help based on an HTML version of the applica- ...