Home | Articles

Text and Related Tutorials

illuminated text Most applications use text in one form or another, and the Java Development Kit (JDK) 1.2 APIs provide a wide range of classes and packages to display, edit, internationalize, and otherwise handle text in applications.

The APIs encompass everything from simple text string and character handling, to foreign language support and stylized graphical text.

You might not design anything as elaborate as this illuminated manuscript from Renaissance France (follow the link to see others), but the JDK 1.2 APIs, especially Java 2D, provide what you would need to do something similar.

This page presents an overview of JDK 1.2 text classes and packages, and links to tutorials where you can learn more.

What is Application Text?

Application text is any writing that appears in the user interface or any application-related files the end user can see. It can be editable, static, or graphical, and is used to present things like labels, dates, the time, numbers, messages, and system properties to the end user. Application text also includes user-supplied or application-generated text.

The Java platform provides the following rich assortment of packages and classes for handling text in all its many forms in applications. All JDK 1.2 text class support the The Unicode Standard--a global character coding system for handling diverse modern, classical, and historical languages.

Where Are the Tutorials?

You can go on to the tutorials listed here for more information on how to use the various JDK 1.2 text packages and classes in your applications.


You will find a tutorial for the Internationalization and localization APIs in the The Java Tutorial. These APIs let you design an application so it can be adapted to different languages and regions without recompilation. The design process is called internationalization, and the addition of locale-specific components and the translation of text is called localization.

The textual data such as messages and GUI component labels, and other culturally-dependent data such as dates and currencies are isolated from the rest of the application in sets of files where one set contains the text for a given language and region. For example, there might be a set of files for French and another set for Canadian French, and because the language code is specified at run time, the same application can be distributed to Canada and France with no modifications to the executable code. By isolating the text to be translated, you also save translation costs.


The JTextComponent class and its descendants implement the editable text components in Swing. Its descendants support plain or styled text with text editing, hit detection, and selection highlighting support. All Swing text components support the unicode character set and can display and handle international languages.

Read How to Use Text Components and How to Use Text Fields in the The Java Tutorial.

Note: The Swing tutorials are a work in progress.

Abstract Window Toolkit (AWT)

The java.awt package supports text-oriented components, graphical text, and stylized text. Of these, only stylized text supports hit detection, selection highlighting, and foreign languages.

© 1994-2005 Sun Microsystems, Inc.