Abdirahim Bin Walid
Abdirahim Bin Walid

Reputation: 21

Launch Applet from JFrame

How can I launch the following applet game from a JFrame?

This is the code for the applet game

import java.applet.*;
import java.awt.*;
import java.awt.event.*;

public class DotsAndBoxes2
            extends Applet
            implements ActionListener, ItemListener, Runnable

This is the code for my JFrame

 private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                         

       this.setVisible(false);
       new DotsAndBoxes2().setVisible(true);
       this.dispose();


    }                              

Upvotes: 2

Views: 1382

Answers (1)

Marcos Vasconcelos
Marcos Vasconcelos

Reputation: 18276

You need to compile the applet and generate a jar file for applets (see how in a applet tutorial)

Then create a simply HTML page witch invoke your applet on screen.

From your JFrame use the method Desktop.browse from the Desktop Java API (http://download.oracle.com/javase/6/docs/api/java/awt/Desktop.html) and pass the URL of the HTML file you created in the last step.

Upvotes: 2

Related Questions