Brandon
Posts: 3
Nickname: brandon
Registered: Dec, 2003
|
|
Re: Help with basic Applet
|
Posted: Dec 22, 2003 11:28 AM
|
|
Ok, in IE/tools/internet options/advanced "use JAVA 2v1.4.2_03 for <applet> is checked.
my applet itself:
/Basic Applet to test program //Calls OhOne
import java.awt.*; import java.awt.event.*; import java.applet.*; import javax.swing.*; import javax.swing.event.*;
public class OhOneGUI extends Applet { //VARIABLES OhOne game; //Starting game objects Choice gameType; Choice numPlayers; Choice difficulty; JButton start; //buttons JButton[] b1 = new JButton[22]; JButton[] b2 = new JButton[22]; JButton[] b3 = new JButton[22]; //labels JLabel[] plr = new JLabel[22]; JLabel info; //textFields JTextField[] plrTxt = new JTextField[22]; JTextField status; //action listener MyListener listener = new MyListener(); //APPLET INITIALIZATION public void init() { setLayout(new GridLayout(3,22, 3, 3)); //initialize items gameType = new Choice(); gameType.add("Select Game"); gameType.add("1"); gameType.add("2"); gameType.add("3"); gameType.add("4"); gameType.add("5"); gameType.add("6"); gameType.add("7"); gameType.add("8"); gameType.add("9"); gameType.add("10"); difficulty = new Choice(); difficulty.add("Select Diff"); difficulty.add("Easy"); difficulty.add("Medium"); difficulty.add("Hard"); numPlayers = new Choice(); numPlayers.add("select Plrs"); for(int i = 1; i < 23; i++) { String temp = ""+ i; numPlayers.add(temp); } start = new JButton("Start"); info = new JLabel("Score Average High Low"); status = new JTextField("Game Not Started"); status.setEnabled(false); b1[20] = new JButton("Bull's Ring"); b1[21] = new JButton("Bull's Eye"); b2[20] = new JButton(""); b2[21] = new JButton("Over"); b3[20] = new JButton(""); b3[21] = new JButton("Reset"); // addButtons(); //} // public void addButtons() // { // removeAll(); add(gameType); add(difficulty); add(numPlayers); add(start); for(int i = 0; i < 20; i++) { int temp = i+1; String t = "" + temp; plr = new JLabel(t); add(plr); plrTxt = new JTextField(); if(i > game.getPlayers()) plrTxt.setEnabled(false); add(plrTxt); b1= new JButton(t); add(b1); String t2 = t + " x2"; b2 = new JButton(t2); add(b2); String t3 = t + " x3"; b3 = new JButton(t3); add(b3); } add(b1[20]); add(b2[20]); add(b3[20]); add(b1[21]); add(b2[21]); add(b3[21]); } //ACTION LISTENER public class MyListener implements ActionListener { public void actionPerformed( ActionEvent event ) {} } }
- it is not complete yet, i would like to beable to view it so i can also test it.
the file structure is: c:\darts\OhOne\ and the 2 class files and the htm file are in this directory.
the htm file looks like this:
<HTML> <HEAD> </HEAD> <BODY> <P> </P>
<APPLET code=OhOneGUI.class height=90% width=90%> <PARAM NAME="foreground" VALUE="FFFFFF"> <PARAM NAME="background" VALUE="008080"> </APPLET>
</BODY> </HTML>
hope someone can make sense of this, thanks for any more help.
|
|