O'Reilly logo

Creating Effective JavaHelp by Kevin Lewis

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Appendix D. TypeFacer.java Source Listing

This appendix contains a listing of the source file, TypeFacer.java, for the Typeface Tester application described in Chapter 7. JavaHelp-related code appears in bold.

/*
 * TypeFacer.java
 * A simple application for styling sample text.
 *
 * This application serves as the basis for JavaHelp demonstrations:
 * screen-level help, field-level help, and embedded help
 */

// ....................................... imports
import java.awt.event.*;
import java.awt.*;
import java.util.Hashtable;
import java.io.*;
import java.net.*;
import javax.swing.*;
import javax.swing.border.*;
import javax.help.*;

// ....................................... TypeFacer (frame)
 
public class TypeFacer extends JFrame {

  // JavaHelp items

           HelpSet hs;
           HelpBroker hb;

  // screen components

  JTextField inputField, displayField;
  JComboBox  fontChoice, foreChoice, backChoice;
  JCheckBox  boldBox, italicBox;
  JButton    showButton, clearButton;
  JButton    helpButton;
           JButton    qButton;

           // embedded help components
           JPanel helpPanel;
           JHelpNavigator nav;
           JHelpContentViewer viewer;

  // menu components

  JMenu     fileMenu, viewMenu;
  JMenuItem exitItem, typeItem, colorItem;
  JMenu helpMenu;
           JMenuItem helpItem;
           JMenuItem helpItemTOC;
           JMenuItem embeddedItem; // frame will contain a panel using the CardLayout manager CardLayout manager; JPanel cards; // fonts and colors for use in display box Hashtable fonts, colors; // combo box choices final String[] fontList = { "TimesRoman", "Helvetica", "Courier" }; final ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required