将Java应用程序转换为applet混淆

时间:2012-03-30 21:46:07

标签: java deployment applet

我正在创建一个Space Invaders类型的克隆,我已经接近完成了。现在的问题是,我想让我的朋友将其发布到他的网站,所以我需要将其转换为应用程序中的applet。我已经在网上查看了一些例子并且玩了一下它并尝试将它放入一个用html制作的简单网页,但我似乎无法让它正常工作。有人可以看看我的代码,并指导我完成这个转换?我非常感谢任何帮助!我正在发布应用程序代码,所以我可能尝试的任何东西都不会混淆。

public class InvadersMain implements KeyListener{

// GUI, Keyboard, Game Data here
private JFrame frame;
private JPanel playArea;
private JPanel sidePanel;
private JLabel scoreLabel;
private JLabel scoreDisplay;
private JLabel livesLabel;
private JLabel livesDisplay;
private JLabel title1;
private JLabel title2;


private final int playWidth = 500;
private final int playHeight = 500;

public String name = "";

public int baddysDead = 0;
public int playerScore = 0;
public int playerLives = 3;
public int waveNumber = 1;
public int waveScore = 20;

public double baddySpeed = 1 + (waveNumber-1)/5000;
// Game Data
private InvadersShip ship;

public ArrayList<InvadersShot> shots;
public ArrayList<InvadersBaddy> baddys;

private boolean shipDead; // Whether or not the ship has been blown up
private long shipTimeOfDeath; // The time at which the ship blew up

// Keyboard data
private boolean rightHeld = false;
private boolean leftHeld = false;
private boolean firing = false;

// Set up the game and play
public InvadersMain(){

    // set everything up
    configureGUI();
    configureGameData();

    // display window
    frame.setVisible(true);

    // start game
    playGame();
    name = JOptionPane.showInputDialog( null, "GAME OVER \nPlease enter your name");

}

我正在尝试隔离需要更改的部件,因此如果需要进一步操作,请告知我们。

public static void main(String[] args){
    new InvadersMain();

}

1 个答案:

答案 0 :(得分:3)

这可能是一个更好的主意 - 而不是试图将方形挂钩(您创建JFrame的程序)推入圆孔(将其更改为小程序),为什么不使用Java Web Start,所以网页可以发布JFrame吗?我认为从长远来看,这会让事情变得更容易。

请看这里:

相关问题