Applet Component

Our point of departure is the same execution flow as for the standalone frame. The only differ-ence is that we don’t have a window that we need to show upon initialization. The browser will manage the applet and bring it to view. Therefore our applet component will not have a main method. On the other hand the applet component will also have a constructor. This constructor will be used by the browser. Therefore it needs to be public. We will again do the initialization of the knowledgebase and the pane at this moment:

     * <p>Setup the knowledgebase and init the pane.</p>
    public Applet() throws InterpreterException, InterpreterMessage {
/* init the pane */
pane.initPane(getRootPane(), this);

/* load the Prolog */
pane.startJob(() -> {
}, new Runnable() {
public void run() {

Since there is no window, we also don’t need to set a title or the default close operation. Removing the applet is managed by the browser. The applet component also provides an action listener. This action listener implements exactly the same logic as the action listener of the standalone frame. We did not go into lengths factoring out this logic into a separate object. As a result the action listener code for the applet component is a copy/paste of the action listener code from the standalone frame. More details are found in the appendix.