Guest_imported
New member
- Jan 1, 1970
- 0
I am writing a simple game that currently runs in a window on the desktop JDK1.3. What do I need to do to get this running as an applet in a browser?? Is there an easy way?
Here the beginning of the source:
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import java.io.BufferedInputStream;
// Create a frame window.
class Game extends Frame {
static Rectangle virtualBounds;
static int screenHeight[] = { 480, 600, 768, 1024, 1050, 1200 };
static Game game;
static Screen screen;
Screen1 screen1 = new Screen1();
Screen2 screen2;
static TextField name;
static Choice opponent, gameChoice, shoice, rChoice;
static Button button, backup, begin,
static MyActionCode ma, mb, mc, me, mr;
static MyItemCode mi, ms, mv, mt;
Game() {
addWindowListener(new MyWindowAdapter());
screen = screen1;
}
public void paint(Graphics g) {
screen.display(g);
}
// Create the window
public static void main(String args[]) {
int i, j;
game = new Game();
game.loadImages();
virtualBounds = new Rectangle();
getScreen1();
}
// Header screen
static void getScreen1() {
game.setLayout( new FlowLayout(FlowLayout.LEFT, 0, virtualBounds.height-(160*virtualBounds.height)/1050) );
game.setBackground(Color.green);
Label label1 = new Label(" First Name:"
name = new TextField(12);
game.add(label1);
game.add(name);
ma = new MyActionCode();
game.name.addActionListener(ma);
Label label2 = new Label(" Number of Opponents:"
opponent = new Choice();
game.add(label2);
game.add(opponent);
opponent.add("4"
opponent.add("5"
opponent.add("6"
mi = new MyItemCode();
opponent.addItemListener(mi);
Label label3 = new Label(" "
game.add(label3);
button = new Button("Begin play"
game.add(button);
mb = new MyActionCode();
button.addActionListener(mb);
game.setVisible(true);
curY = initialY; }
class Screen {
Here the beginning of the source:
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import java.io.BufferedInputStream;
// Create a frame window.
class Game extends Frame {
static Rectangle virtualBounds;
static int screenHeight[] = { 480, 600, 768, 1024, 1050, 1200 };
static Game game;
static Screen screen;
Screen1 screen1 = new Screen1();
Screen2 screen2;
static TextField name;
static Choice opponent, gameChoice, shoice, rChoice;
static Button button, backup, begin,
static MyActionCode ma, mb, mc, me, mr;
static MyItemCode mi, ms, mv, mt;
Game() {
addWindowListener(new MyWindowAdapter());
screen = screen1;
}
public void paint(Graphics g) {
screen.display(g);
}
// Create the window
public static void main(String args[]) {
int i, j;
game = new Game();
game.loadImages();
virtualBounds = new Rectangle();
getScreen1();
}
// Header screen
static void getScreen1() {
game.setLayout( new FlowLayout(FlowLayout.LEFT, 0, virtualBounds.height-(160*virtualBounds.height)/1050) );
game.setBackground(Color.green);
Label label1 = new Label(" First Name:"
name = new TextField(12);
game.add(label1);
game.add(name);
ma = new MyActionCode();
game.name.addActionListener(ma);
Label label2 = new Label(" Number of Opponents:"
opponent = new Choice();
game.add(label2);
game.add(opponent);
opponent.add("4"
opponent.add("5"
opponent.add("6"
mi = new MyItemCode();
opponent.addItemListener(mi);
Label label3 = new Label(" "
game.add(label3);
button = new Button("Begin play"
game.add(button);
mb = new MyActionCode();
button.addActionListener(mb);
game.setVisible(true);
curY = initialY; }
class Screen {