Top
Interstage Studio J Business Kit User's Guide
FUJITSU Software

2.3.5 Using the Java Console

This section describes the Java console of JBK Plugin.

JBK Plugin provides the Java console that displays useful information for debugging an applet. The Java console displays the following information:

The Java console has two buttons:

In addition, the Java console allows the following operations to be performed with the associated keys:

C

Clears the Java console.

G

Executes garbage collection.

H

Shows keyboard help.

M

Shows the amount of memory being used.

S

Outputs the system properties.

T

Outputs the thread list.

0

Switches between JBK Plugin trace outputs (Traces of class loadings or HTTP connection states.).

Ctrl+Shift+E

Switches between AWTEvent trace outputs (Traces of FocusEvent, KeyEvent, MouseEvent, and WindowEvent.).

Displaying or Hiding the Java Console

The Java console is not displayed by the default (initial) setting specified when JBK Plugin is installed.To display or hide the Java console when JBK Plugin starts to run, code the following line into the jbkplugin.properties file:

jbk.plugin.console.visible=<Java-console-displayed-or-hidden>

As <Java-console-displayed-or-hidden>, specify either of the following:

true

Displays the Java console.

false

Hides the Java console. (default)

To redisplay the Java Console once it has been hidden, press [Ctrl]+[Alt]+[Insert] when the applet has the focus.

Displaying or Hiding the Java Console from an Applet

JBK Plugin provides the PluginAppletContext interface for displaying or hiding the Java console from an applet.

The API of the PluginAppletContext interface is as shown below:

The class file for the PluginAppletContext interface is stored in the jar file for the development of the JBK plugin ("classes\jbkstd.jar" in the JBK installation folder). When compiling the class of an applet that uses the PluginAppletContext interface, check whether the jar file for the development of the JBK plugin is included in the classpath.

The PluginAppletContext instance can be obtained by invoking the getAppletContext() method of java.applet.Applet class. The following is an example of the applet using this functionality, which acts as a button to show the Java console.

Table 2.2 Applet having the Java console display button
import java.applet.*;
import java.awt.*;
import java.awt.event.*;

import com.fujitsu.jbk.plugin.browser.PluginAppletContext;

/**
 * This applet acts as a button to show the Java console.
 */
public class ConsoleButton extends Applet implements ActionListener {
    /**
     * Initializes the applet.
     */
    public void init() {
        // Creates a button to show the Java console.
        setLayout(new BorderLayout());
        Button b = new Button("Show the Java console");
        b.addActionListener(this);
        add(b);
    }

    /**
     * Invoked when the button is pressed.
     */
    public void actionPerformed(ActionEvent e) {
        // Gets the AppletContext.
        AppletContext context = getAppletContext();

        try {
            // Checks whether the AppletContext is an instance of the PluginAppletContext
            if (context instanceof PluginAppletContext) {
                PluginAppletContext plgContext = (PluginAppletContext)context;
                // Show the Java console if it is not shown.
                if (!plgContext.isConsoleVisible()) {
                    plgContext.setConsoleVisible(true);
                }
            }
        } catch (Throwable ignore) {
            /* do nothing */
        }
    }
}