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:
Messages output to the standard output (System.out) or standard error output (System.err) when the applet is executed
Messages displayed in the status window of the browser when the showStatus() method of the AppletContext class is executed
Messages indicating exceptions occurring when an applet is executed
Figure 2.2 The Java console of JBK Plugin
The Java console has two buttons:
"Clear" - Erases all the displayed information.
"Close" - Hides the Java console.
In addition, the Java console allows the following operations to be performed with the associated keys:
Clears the Java console.
Executes garbage collection.
Shows keyboard help.
Shows the amount of memory being used.
Outputs the system properties.
Outputs the thread list.
Switches between JBK Plugin trace outputs (Traces of class loadings or HTTP connection states.).
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:
Displays the Java console.
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:
Interface
com.fujitsu.jbk.plugin.browser.PluginAppletContext
(extends java.applet.AppletContext)
Methods
setConsoleVisible
Displays or hides the Java console.
public abstract void setConsoleVisible(boolean visible) |
true:The Java console is displayed.
fals:The Java console is hidden.
isConsoleVisible
Returns whether the Java console is displayed or not.
public abstract boolean isConsoleVisible() |
Returns true when the Java console is displayed. Returns false when the Java console is hidden.
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.
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 */ } } } |