CHARVA: A Java Windowing Toolkit for Text Terminals
Keywords: java, text, terminal, user, interface, VT100, curses, ncurses

# A Java Windowing Toolkit for Text Terminals

Menu
Introduction
Features
Status
FAQ
Licence
Screenshots
Documentation
Download
Applications
Support
Contribute
Quick Info
Operating System: Linux
Language: Java, C
Licence: GNU
Author: Rob Pitman
Features
The CHARVA Toolkit emulates the functionality of the standard AWT (Abstract Windowing Toolkit) and "Swing" classes (collectively known as the Java Foundation Classes) as far as possible. In fact, my original intention was to use exactly the same API as the AWT. Theoretically this should be possible, because the AWT can in theory have many different implementations (that is why it was named the Abstract Windowing Toolkit). Stuart Gathman has already written a package called TUIPEER that implements the AWT API for ASCII terminals. Stuart's package was written with JDK 1.1.x, and did not use the `ncurses` library or the JNI (Java Native Interface). I found that it was not possible to port TUIPEER from JDK 1.1.x to JDK 1.2 or JDK 1.3, because in later versions of the JDK Sun had forced implementations of the AWT to subclass Sun proprietary classes. So I wrote CHARVA from scratch. I tried to maintain compatibility as far as possible with the AWT and Swing APIs; in the source code of your Java program, just change package references from "java.awt" to "charva.awt", and from "javax.swing" to "charvax.swing" to port the program from Swing to CHARVA. Since version 1.0.0, CHARVA provides mouse support (only on terminal-emulators that report mouse events, such as xterm and PuTTY). Of course, CHARVA does not support GUI-type features such as cut-and-paste and drag-and-drop. But it provides most of the standard "graphical" AWT-compatible base classes such as Point, Rectangle, Dimension, Component, Container, Window, Frame, Dialog, etc. It also provides the FlowLayout, BoxLayout, BorderLayout and GridBagLayout geometry managers. CHARVA also provides the following classes which are designed to be compatible with their Swing counterparts (see the Javadoc-generated API documentation for details): Box, BoxLayout, ButtonGroup and JRadioButton, JButton, JCheckBox, JComponent, JComboBox, JDialog, JFileChooser, JFrame, JLabel, JList, JMenuBar, JMenuItem, JMenu, JOptionPane, JPanel, JPasswordField, JProgressBar, JScrollBar, JScrollPane, JTabbedPane, JTable, JTextArea, JTextField, JViewport. The JList, JTable and JTextArea are typically displayed inside a JScrollPane (in the same manner as the corresponding Swing versions of these components). CHARVA supports any terminal that has a "terminfo" capability-description file; in other words, all popular terminals such as VT100, VT220, Wyse and ANSI terminals and the "xterm" and "PuTTY" terminal emulators are supported. CHARVA supports color on terminals that have color capability, such as the ANSI terminal, "xterm" and "PuTTY". Uncaught exceptions, error messages and diagnostic messages are logged using Jakarta Commons Logging. The "stderr" stream must be redirected to a logfile or some other logging machanism before any CHARVA class is instantiated (typically this is done in the script file that starts the Java application). Event-handling is performed with the same delegation model as the AWT uses. Each object that generates events can register "Listener" objects that will receive and act on those events. The available events form a subset of the events used in the AWT. In short, if you are familiar with programming with AWT and Swing, you will have no problems with using CHARVA. If you aren't familiar with AWT, read the following reference: Chapters 8 and 9 of Core Java 2 - Volume1: Fundamentals by Cay Horstmann and Gary Cornell (Prentice Hall), ISBN 0-13-081933-6.

Last updated: 14 August, 2006