Category: Text Components

Text Components

Highlighters

Highlighters

Highlighters determine how text is marked to make it stand out. The order in which we discuss the highlighter interfaces may seem counterintuitive. The basic Highlighter interface is so straightforward that you’ll rarely need...

The JTextPane Class

The JTextPane Class

JTextPane is a multiline text component that can display text with multiple fonts, colors, and even embedded images. It supports named hierarchical text styles and has other features that can help implement a word...

Formatted Text Fields

Formatted Text Fields

Swing provides extended functionality for text fields through the JFormattedTextField class introduced in SDK 1.4. A JFormattedTextField can display its value in a friendly (and locale-specific) way, enforce restrictions on its value, be used...

The JTextArea Class

The JTextArea Class

The JTextArea class displays multiple lines of text in a single font and style. Its default behavior is not to wrap lines of text, but line-wrapping can be enabled on word or character boundaries....

A Simple Swing Form

A Simple Swing Form

One of the most common user-interface constructs is the basic form. Typically, forms are made up of labels and fields, with the label describing the text to be entered in the field. Here’s a...

The JTextField Class

The JTextField Class

JTextField allows the user to enter a single line of text, scrolling the text if its size exceeds the physical size of the field. A JTextField fires an ActionEvent to any registered ActionListeners (including...

The Swing Text Components

The Swing Text Components

Swing provides an extensive collection of classes for working with text in user interfaces. In fact, because there’s so much provided for working with text, Swing’s creators placed most of it into its own...