Re: applet- help- the code


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: Re: applet- help- the code

Hybrid View

  1. #1
    shafi Guest

    Re: applet- help- the code


    Applet cant be intstantiated

    help. I have ie 5.5

    this the code. Fiirst day programming in java.

    package thegamethree;

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

    public class tictactoe extends Applet {
    boolean isStandalone = false;
    boolean whoturn = true; // True - X False - O
    boolean enabledbutton[] = new boolean[10];
    String XorO[] = new String [10];


    JButton jBtn[] = new JButton[10];
    JButton jBtn1 = new JButton();
    JButton jBtn2 = new JButton();
    JButton jBtn3 = new JButton();
    JButton jBtn6 = new JButton();
    JButton jBtn5 = new JButton();
    JButton jBtn4 = new JButton();
    JButton jBtn9 = new JButton();
    JButton jBtn8 = new JButton();
    JButton jBtn7 = new JButton();
    JLabel jLabel1 = new JLabel();
    JLabel jLblwhoturn = new JLabel();
    /**Get a parameter value*/
    public String getParameter(String key, String def) {
    return isStandalone ? System.getProperty(key, def) :
    (getParameter(key) != null ? getParameter(key) : def);
    }

    /**Construct the applet*/
    public tictactoe() {
    }
    /**Initialize the applet*/
    public void init() {

    try {
    jbInit();
    }
    catch(Exception e) {
    e.printStackTrace();
    }
    jBtn[1] = jBtn1;
    jBtn[2] = jBtn2;
    jBtn[3] = jBtn3;
    jBtn[4] = jBtn4;
    jBtn[5] = jBtn5;
    jBtn[6] = jBtn6;
    jBtn[7] = jBtn7;
    jBtn[8] = jBtn8;
    jBtn[9] = jBtn9;
    enabledbutton[1] = true;
    enabledbutton[2] = true;
    enabledbutton[3] = true;
    enabledbutton[4] = true;
    enabledbutton[5] = true;
    enabledbutton[6] = true;
    enabledbutton[7] = true;
    enabledbutton[8] = true;
    enabledbutton[9] = true;
    XorO[1] = "f";
    XorO[2] = "f";
    XorO[3] = "f";
    XorO[4] = "f";
    XorO[5] = "f";
    XorO[6] = "f";
    XorO[7] = "f";
    XorO[8] = "f";
    XorO[9] = "f";

    }



    /**Component initialization*/
    private void jbInit() throws Exception {
    this.setLayout(null);
    jBtn1.setBounds(new Rectangle(79, 58, 74, 80));
    jBtn1.addMouseListener(new java.awt.event.MouseAdapter() {
    public void mouseClicked(MouseEvent e) {
    jBtn1_mouseClicked(e);
    }
    });
    jBtn1.setToolTipText("");
    jBtn1.setMnemonic('1');
    jBtn1.setFont(new java.awt.Font("Dialog", 0, 40));
    jBtn2.setFont(new java.awt.Font("Dialog", 0, 40));
    jBtn2.setToolTipText("");
    jBtn2.setMnemonic('2');
    jBtn2.setBounds(new Rectangle(155, 58, 74, 80));
    jBtn2.addMouseListener(new java.awt.event.MouseAdapter() {
    public void mouseClicked(MouseEvent e) {
    jBtn2_mouseClicked(e);
    }
    });
    jBtn3.setFont(new java.awt.Font("Dialog", 0, 40));
    jBtn3.setToolTipText("");
    jBtn3.setMnemonic('9');
    jBtn3.setBounds(new Rectangle(232, 58, 74, 80));
    jBtn3.addMouseListener(new java.awt.event.MouseAdapter() {
    public void mouseClicked(MouseEvent e) {
    jBtn3_mouseClicked(e);
    }
    });
    jBtn6.setBounds(new Rectangle(231, 139, 74, 80));
    jBtn6.addMouseListener(new java.awt.event.MouseAdapter() {
    public void mouseClicked(MouseEvent e) {
    jBtn6_mouseClicked(e);
    }
    });
    jBtn6.setToolTipText("");
    jBtn6.setMnemonic('0');
    jBtn6.setFont(new java.awt.Font("Dialog", 0, 40));
    jBtn5.addMouseListener(new java.awt.event.MouseAdapter() {
    public void mouseClicked(MouseEvent e) {
    jBtn5_mouseClicked(e);
    }
    });
    jBtn5.setBounds(new Rectangle(154, 140, 74, 80));
    jBtn5.setToolTipText("");
    jBtn5.setFont(new java.awt.Font("Dialog", 0, 40));
    jBtn4.setFont(new java.awt.Font("Dialog", 0, 40));
    jBtn4.setToolTipText("");
    jBtn4.setBounds(new Rectangle(78, 140, 74, 80));
    jBtn4.addMouseListener(new java.awt.event.MouseAdapter() {
    public void mouseClicked(MouseEvent e) {
    jBtn4_mouseClicked(e);
    }
    });
    jBtn9.setBounds(new Rectangle(231, 221, 74, 80));
    jBtn9.addMouseListener(new java.awt.event.MouseAdapter() {
    public void mouseClicked(MouseEvent e) {
    jBtn9_mouseClicked(e);
    }
    });
    jBtn9.setToolTipText("");
    jBtn9.setFont(new java.awt.Font("Dialog", 0, 40));
    jBtn8.addMouseListener(new java.awt.event.MouseAdapter() {
    public void mouseClicked(MouseEvent e) {
    jBtn8_mouseClicked(e);
    }
    });
    jBtn8.setBounds(new Rectangle(155, 221, 74, 80));
    jBtn8.setToolTipText("");
    jBtn8.setFont(new java.awt.Font("Dialog", 0, 40));
    jBtn7.setFont(new java.awt.Font("Dialog", 0, 40));
    jBtn7.setToolTipText("");
    jBtn7.setBounds(new Rectangle(79, 221, 74, 80));
    jBtn7.addMouseListener(new java.awt.event.MouseAdapter() {
    public void mouseClicked(MouseEvent e) {
    jBtn7_mouseClicked(e);
    }
    });
    jLabel1.setFont(new java.awt.Font("Dialog", 0, 25));
    jLabel1.setText("TicTacToe made by Shafi");
    jLabel1.setBounds(new Rectangle(52, 9, 306, 52));
    jLblwhoturn.setFont(new java.awt.Font("Dialog", 1, 50));
    jLblwhoturn.setToolTipText("");
    jLblwhoturn.setText("X - Turn");
    jLblwhoturn.setBounds(new Rectangle(95, 318, 202, 61));
    this.setBackground(UIManager.getColor("EditorPane.caretForeground"));
    this.setForeground(Color.white);
    this.add(jLabel1, null);
    this.add(jBtn2, null);
    this.add(jBtn1, null);
    this.add(jBtn3, null);
    this.add(jBtn6, null);
    this.add(jBtn5, null);
    this.add(jBtn4, null);
    this.add(jBtn7, null);
    this.add(jBtn8, null);
    this.add(jBtn9, null);
    this.add(jLblwhoturn, null);
    }
    /**Get Applet information*/
    public String getAppletInfo() {
    return "Applet Information";

    }
    /**Get parameter info*/
    public String[][] getParameterInfo() {
    return null;
    }



    void jBtn2_mouseClicked(MouseEvent e) {
    int ix = 2;


    if (enabledbutton[ix]) {
    if (whoturn) {
    jBtn[ix].setText("X");
    whoturn = false;
    jLblwhoturn.setText("O - Turn");
    XorO[ix] = "X";
    }
    else {
    jBtn[ix].setText("O");
    whoturn = true;
    jLblwhoturn.setText("X - Turn");
    XorO[ix] = "O";
    }

    jBtn[ix].setEnabled(false);
    }
    enabledbutton[ix] = false;


    //tring sx = "X";



    if ( ( XorO[1] == "X" & XorO[2] == "X" & XorO[3] == "X")
    | ( XorO[4] == "X" & XorO[5] == "X" & XorO[6] == "X")
    | ( XorO[7] == "X" & XorO[8] == "X" & XorO[9] == "X")

    | ( XorO[1] == "X" & XorO[4] == "X" & XorO[7] == "X")
    | ( XorO[2] == "X" & XorO[5] == "X" & XorO[8] == "X")
    | ( XorO[3] == "X" & XorO[6] == "X" & XorO[9] == "X")

    | ( XorO[1] == "X" & XorO[5] == "X" & XorO[9] == "X")
    | ( XorO[3] == "X" & XorO[5] == "X" & XorO[7] == "X") )

    {
    jLblwhoturn.setText("X - Wins");
    }

    if ( ( XorO[1] == "O" & XorO[2] == "O" & XorO[3] == "O")
    | ( XorO[4] == "O" & XorO[5] == "O" & XorO[6] == "O")
    | ( XorO[7] == "O" & XorO[8] == "O" & XorO[9] == "O")

    | ( XorO[1] == "O" & XorO[4] == "O" & XorO[7] == "O")
    | ( XorO[2] == "O" & XorO[5] == "O" & XorO[8] == "O")
    | ( XorO[3] == "O" & XorO[6] == "O" & XorO[9] == "O")

    | ( XorO[1] == "O" & XorO[5] == "O" & XorO[9] == "O")
    | ( XorO[3] == "O" & XorO[5] == "O" & XorO[7] == "O") )

    {
    jLblwhoturn.setText("0 - Wins");
    }

    }


    void jBtn5_mouseClicked(MouseEvent e) {
    int ix = 5;


    if (enabledbutton[ix]) {
    if (whoturn) {
    jBtn[ix].setText("X");
    whoturn = false;
    jLblwhoturn.setText("O - Turn");
    XorO[ix] = "X";
    }
    else {
    jBtn[ix].setText("O");
    whoturn = true;
    jLblwhoturn.setText("X - Turn");
    XorO[ix] = "O";
    }

    jBtn[ix].setEnabled(false);
    }
    enabledbutton[ix] = false;


    if ( ( XorO[1] == "X" & XorO[2] == "X" & XorO[3] == "X")
    | ( XorO[4] == "X" & XorO[5] == "X" & XorO[6] == "X")
    | ( XorO[7] == "X" & XorO[8] == "X" & XorO[9] == "X")

    | ( XorO[1] == "X" & XorO[4] == "X" & XorO[7] == "X")
    | ( XorO[2] == "X" & XorO[5] == "X" & XorO[8] == "X")
    | ( XorO[3] == "X" & XorO[6] == "X" & XorO[9] == "X")

    | ( XorO[1] == "X" & XorO[5] == "X" & XorO[9] == "X")
    | ( XorO[3] == "X" & XorO[5] == "X" & XorO[7] == "X") )

    {
    jLblwhoturn.setText("X - Wins");
    }

    if ( ( XorO[1] == "O" & XorO[2] == "O" & XorO[3] == "O")
    | ( XorO[4] == "O" & XorO[5] == "O" & XorO[6] == "O")
    | ( XorO[7] == "O" & XorO[8] == "O" & XorO[9] == "O")

    | ( XorO[1] == "O" & XorO[4] == "O" & XorO[7] == "O")
    | ( XorO[2] == "O" & XorO[5] == "O" & XorO[8] == "O")
    | ( XorO[3] == "O" & XorO[6] == "O" & XorO[9] == "O")

    | ( XorO[1] == "O" & XorO[5] == "O" & XorO[9] == "O")
    | ( XorO[3] == "O" & XorO[5] == "O" & XorO[7] == "O") )

    {
    jLblwhoturn.setText("0 - Wins");
    }




    }

    void jBtn8_mouseClicked(MouseEvent e) {
    int ix = 8;


    if (enabledbutton[ix]) {
    if (whoturn) {
    jBtn[ix].setText("X");
    whoturn = false;
    jLblwhoturn.setText("O - Turn");
    XorO[ix] = "X";
    }
    else {
    jBtn[ix].setText("O");
    whoturn = true;
    jLblwhoturn.setText("X - Turn");
    XorO[ix] = "O";
    }

    jBtn[ix].setEnabled(false);
    }
    enabledbutton[ix] = false;


    if ( ( XorO[1] == "X" & XorO[2] == "X" & XorO[3] == "X")
    | ( XorO[4] == "X" & XorO[5] == "X" & XorO[6] == "X")
    | ( XorO[7] == "X" & XorO[8] == "X" & XorO[9] == "X")

    | ( XorO[1] == "X" & XorO[4] == "X" & XorO[7] == "X")
    | ( XorO[2] == "X" & XorO[5] == "X" & XorO[8] == "X")
    | ( XorO[3] == "X" & XorO[6] == "X" & XorO[9] == "X")

    | ( XorO[1] == "X" & XorO[5] == "X" & XorO[9] == "X")
    | ( XorO[3] == "X" & XorO[5] == "X" & XorO[7] == "X") )

    {
    jLblwhoturn.setText("X - Wins");
    }

    if ( ( XorO[1] == "O" & XorO[2] == "O" & XorO[3] == "O")
    | ( XorO[4] == "O" & XorO[5] == "O" & XorO[6] == "O")
    | ( XorO[7] == "O" & XorO[8] == "O" & XorO[9] == "O")

    | ( XorO[1] == "O" & XorO[4] == "O" & XorO[7] == "O")
    | ( XorO[2] == "O" & XorO[5] == "O" & XorO[8] == "O")
    | ( XorO[3] == "O" & XorO[6] == "O" & XorO[9] == "O")

    | ( XorO[1] == "O" & XorO[5] == "O" & XorO[9] == "O")
    | ( XorO[3] == "O" & XorO[5] == "O" & XorO[7] == "O") )

    {
    jLblwhoturn.setText("0 - Wins");
    }


    }

    void jBtn1_mouseClicked(MouseEvent e) {
    int ix = 1;


    if (enabledbutton[ix]) {
    if (whoturn) {
    jBtn[ix].setText("X");
    whoturn = false;
    jLblwhoturn.setText("O - Turn");
    XorO[ix] = "X";
    }
    else {
    jBtn[ix].setText("O");
    whoturn = true;
    jLblwhoturn.setText("X - Turn");
    XorO[ix] = "O";
    }

    jBtn[ix].setEnabled(false);
    }
    enabledbutton[ix] = false;


    if ( ( XorO[1] == "X" & XorO[2] == "X" & XorO[3] == "X")
    | ( XorO[4] == "X" & XorO[5] == "X" & XorO[6] == "X")
    | ( XorO[7] == "X" & XorO[8] == "X" & XorO[9] == "X")

    | ( XorO[1] == "X" & XorO[4] == "X" & XorO[7] == "X")
    | ( XorO[2] == "X" & XorO[5] == "X" & XorO[8] == "X")
    | ( XorO[3] == "X" & XorO[6] == "X" & XorO[9] == "X")

    | ( XorO[1] == "X" & XorO[5] == "X" & XorO[9] == "X")
    | ( XorO[3] == "X" & XorO[5] == "X" & XorO[7] == "X") )

    {
    jLblwhoturn.setText("X - Wins");
    }

    if ( ( XorO[1] == "O" & XorO[2] == "O" & XorO[3] == "O")
    | ( XorO[4] == "O" & XorO[5] == "O" & XorO[6] == "O")
    | ( XorO[7] == "O" & XorO[8] == "O" & XorO[9] == "O")

    | ( XorO[1] == "O" & XorO[4] == "O" & XorO[7] == "O")
    | ( XorO[2] == "O" & XorO[5] == "O" & XorO[8] == "O")
    | ( XorO[3] == "O" & XorO[6] == "O" & XorO[9] == "O")

    | ( XorO[1] == "O" & XorO[5] == "O" & XorO[9] == "O")
    | ( XorO[3] == "O" & XorO[5] == "O" & XorO[7] == "O") )

    {
    jLblwhoturn.setText("0 - Wins");
    }



    }

    void jBtn3_mouseClicked(MouseEvent e) {
    int ix = 3;


    if (enabledbutton[ix]) {
    if (whoturn) {
    jBtn[ix].setText("X");
    whoturn = false;
    jLblwhoturn.setText("O - Turn");
    XorO[ix] = "X";
    }
    else {
    jBtn[ix].setText("O");
    whoturn = true;
    jLblwhoturn.setText("X - Turn");
    XorO[ix] = "O";
    }

    jBtn[ix].setEnabled(false);
    }
    enabledbutton[ix] = false;


    if ( ( XorO[1] == "X" & XorO[2] == "X" & XorO[3] == "X")
    | ( XorO[4] == "X" & XorO[5] == "X" & XorO[6] == "X")
    | ( XorO[7] == "X" & XorO[8] == "X" & XorO[9] == "X")

    | ( XorO[1] == "X" & XorO[4] == "X" & XorO[7] == "X")
    | ( XorO[2] == "X" & XorO[5] == "X" & XorO[8] == "X")
    | ( XorO[3] == "X" & XorO[6] == "X" & XorO[9] == "X")

    | ( XorO[1] == "X" & XorO[5] == "X" & XorO[9] == "X")
    | ( XorO[3] == "X" & XorO[5] == "X" & XorO[7] == "X") )

    {
    jLblwhoturn.setText("X - Wins");
    }

    if ( ( XorO[1] == "O" & XorO[2] == "O" & XorO[3] == "O")
    | ( XorO[4] == "O" & XorO[5] == "O" & XorO[6] == "O")
    | ( XorO[7] == "O" & XorO[8] == "O" & XorO[9] == "O")

    | ( XorO[1] == "O" & XorO[4] == "O" & XorO[7] == "O")
    | ( XorO[2] == "O" & XorO[5] == "O" & XorO[8] == "O")
    | ( XorO[3] == "O" & XorO[6] == "O" & XorO[9] == "O")

    | ( XorO[1] == "O" & XorO[5] == "O" & XorO[9] == "O")
    | ( XorO[3] == "O" & XorO[5] == "O" & XorO[7] == "O") )

    {
    jLblwhoturn.setText("0 - Wins");
    }

    }

    void jBtn4_mouseClicked(MouseEvent e) {
    int ix = 4;


    if (enabledbutton[ix]) {
    if (whoturn) {
    jBtn[ix].setText("X");
    whoturn = false;
    jLblwhoturn.setText("O - Turn");
    XorO[ix] = "X";
    }
    else {
    jBtn[ix].setText("O");
    whoturn = true;
    jLblwhoturn.setText("X - Turn");
    XorO[ix] = "O";
    }

    jBtn[ix].setEnabled(false);
    }
    enabledbutton[ix] = false;

    if ( ( XorO[1] == "X" & XorO[2] == "X" & XorO[3] == "X")
    | ( XorO[4] == "X" & XorO[5] == "X" & XorO[6] == "X")
    | ( XorO[7] == "X" & XorO[8] == "X" & XorO[9] == "X")

    | ( XorO[1] == "X" & XorO[4] == "X" & XorO[7] == "X")
    | ( XorO[2] == "X" & XorO[5] == "X" & XorO[8] == "X")
    | ( XorO[3] == "X" & XorO[6] == "X" & XorO[9] == "X")

    | ( XorO[1] == "X" & XorO[5] == "X" & XorO[9] == "X")
    | ( XorO[3] == "X" & XorO[5] == "X" & XorO[7] == "X") )

    {
    jLblwhoturn.setText("X - Wins");
    }

    if ( ( XorO[1] == "O" & XorO[2] == "O" & XorO[3] == "O")
    | ( XorO[4] == "O" & XorO[5] == "O" & XorO[6] == "O")
    | ( XorO[7] == "O" & XorO[8] == "O" & XorO[9] == "O")

    | ( XorO[1] == "O" & XorO[4] == "O" & XorO[7] == "O")
    | ( XorO[2] == "O" & XorO[5] == "O" & XorO[8] == "O")
    | ( XorO[3] == "O" & XorO[6] == "O" & XorO[9] == "O")

    | ( XorO[1] == "O" & XorO[5] == "O" & XorO[9] == "O")
    | ( XorO[3] == "O" & XorO[5] == "O" & XorO[7] == "O") )

    {
    jLblwhoturn.setText("0 - Wins");
    }

    }

    void jBtn6_mouseClicked(MouseEvent e) {
    int ix = 6;


    if (enabledbutton[ix]) {
    if (whoturn) {
    jBtn[ix].setText("X");
    whoturn = false;
    jLblwhoturn.setText("O - Turn");
    XorO[ix] = "X";
    }
    else {
    jBtn[ix].setText("O");
    whoturn = true;
    jLblwhoturn.setText("X - Turn");
    XorO[ix] = "O";
    }

    jBtn[ix].setEnabled(false);
    }
    enabledbutton[ix] = false;

    if ( ( XorO[1] == "X" & XorO[2] == "X" & XorO[3] == "X")
    | ( XorO[4] == "X" & XorO[5] == "X" & XorO[6] == "X")
    | ( XorO[7] == "X" & XorO[8] == "X" & XorO[9] == "X")

    | ( XorO[1] == "X" & XorO[4] == "X" & XorO[7] == "X")
    | ( XorO[2] == "X" & XorO[5] == "X" & XorO[8] == "X")
    | ( XorO[3] == "X" & XorO[6] == "X" & XorO[9] == "X")

    | ( XorO[1] == "X" & XorO[5] == "X" & XorO[9] == "X")
    | ( XorO[3] == "X" & XorO[5] == "X" & XorO[7] == "X") )

    {
    jLblwhoturn.setText("X - Wins");
    }

    if ( ( XorO[1] == "O" & XorO[2] == "O" & XorO[3] == "O")
    | ( XorO[4] == "O" & XorO[5] == "O" & XorO[6] == "O")
    | ( XorO[7] == "O" & XorO[8] == "O" & XorO[9] == "O")

    | ( XorO[1] == "O" & XorO[4] == "O" & XorO[7] == "O")
    | ( XorO[2] == "O" & XorO[5] == "O" & XorO[8] == "O")
    | ( XorO[3] == "O" & XorO[6] == "O" & XorO[9] == "O")

    | ( XorO[1] == "O" & XorO[5] == "O" & XorO[9] == "O")
    | ( XorO[3] == "O" & XorO[5] == "O" & XorO[7] == "O") )

    {
    jLblwhoturn.setText("0 - Wins");
    }

    }

    void jBtn7_mouseClicked(MouseEvent e) {
    int ix = 7;


    if (enabledbutton[ix]) {
    if (whoturn) {
    jBtn[ix].setText("X");
    whoturn = false;
    jLblwhoturn.setText("O - Turn");
    XorO[ix] = "X";
    }
    else {
    jBtn[ix].setText("O");
    whoturn = true;
    jLblwhoturn.setText("X - Turn");
    XorO[ix] = "O";
    }

    jBtn[ix].setEnabled(false);
    }
    enabledbutton[ix] = false;
    if ( ( XorO[1] == "X" & XorO[2] == "X" & XorO[3] == "X")
    | ( XorO[4] == "X" & XorO[5] == "X" & XorO[6] == "X")
    | ( XorO[7] == "X" & XorO[8] == "X" & XorO[9] == "X")

    | ( XorO[1] == "X" & XorO[4] == "X" & XorO[7] == "X")
    | ( XorO[2] == "X" & XorO[5] == "X" & XorO[8] == "X")
    | ( XorO[3] == "X" & XorO[6] == "X" & XorO[9] == "X")

    | ( XorO[1] == "X" & XorO[5] == "X" & XorO[9] == "X")
    | ( XorO[3] == "X" & XorO[5] == "X" & XorO[7] == "X") )

    {
    jLblwhoturn.setText("X - Wins");
    }

    if ( ( XorO[1] == "O" & XorO[2] == "O" & XorO[3] == "O")
    | ( XorO[4] == "O" & XorO[5] == "O" & XorO[6] == "O")
    | ( XorO[7] == "O" & XorO[8] == "O" & XorO[9] == "O")

    | ( XorO[1] == "O" & XorO[4] == "O" & XorO[7] == "O")
    | ( XorO[2] == "O" & XorO[5] == "O" & XorO[8] == "O")
    | ( XorO[3] == "O" & XorO[6] == "O" & XorO[9] == "O")

    | ( XorO[1] == "O" & XorO[5] == "O" & XorO[9] == "O")
    | ( XorO[3] == "O" & XorO[5] == "O" & XorO[7] == "O") )

    {
    jLblwhoturn.setText("0 - Wins");
    }


    }

    void jBtn9_mouseClicked(MouseEvent e) {
    int ix = 9;


    if (enabledbutton[ix]) {
    if (whoturn) {
    jBtn[ix].setText("X");
    whoturn = false;
    jLblwhoturn.setText("O - Turn");
    XorO[ix] = "X";
    }
    else {
    jBtn[ix].setText("O");
    whoturn = true;
    jLblwhoturn.setText("X - Turn");
    XorO[ix] = "O";
    }

    jBtn[ix].setEnabled(false);
    }
    enabledbutton[ix] = false;

    if ( ( XorO[1] == "X" & XorO[2] == "X" & XorO[3] == "X")
    | ( XorO[4] == "X" & XorO[5] == "X" & XorO[6] == "X")
    | ( XorO[7] == "X" & XorO[8] == "X" & XorO[9] == "X")

    | ( XorO[1] == "X" & XorO[4] == "X" & XorO[7] == "X")
    | ( XorO[2] == "X" & XorO[5] == "X" & XorO[8] == "X")
    | ( XorO[3] == "X" & XorO[6] == "X" & XorO[9] == "X")

    | ( XorO[1] == "X" & XorO[5] == "X" & XorO[9] == "X")
    | ( XorO[3] == "X" & XorO[5] == "X" & XorO[7] == "X") )

    {
    jLblwhoturn.setText("X - Wins");
    }

    if ( ( XorO[1] == "O" & XorO[2] == "O" & XorO[3] == "O")
    | ( XorO[4] == "O" & XorO[5] == "O" & XorO[6] == "O")
    | ( XorO[7] == "O" & XorO[8] == "O" & XorO[9] == "O")

    | ( XorO[1] == "O" & XorO[4] == "O" & XorO[7] == "O")
    | ( XorO[2] == "O" & XorO[5] == "O" & XorO[8] == "O")
    | ( XorO[3] == "O" & XorO[6] == "O" & XorO[9] == "O")

    | ( XorO[1] == "O" & XorO[5] == "O" & XorO[9] == "O")
    | ( XorO[3] == "O" & XorO[5] == "O" & XorO[7] == "O") )

    {
    jLblwhoturn.setText("0 - Wins");
    }

    }
    }



  2. #2
    Ako Guest

    Re: applet- help- the code


    i dont have time to go through your code (sorry) but i used appletviewer to
    run your code, it does run but with alot of error and exception messages,
    i got so many compiler output lines and because im using dos shel i only
    see the last few ones so cant help right now.
    If you use an IDE or just JDK on Linux you will be able to see all the error
    messages and exceptions while the program is running or you can even use
    the built in debugger of your compiler.
    Having a program that compiles does not mean that the program will do exactly
    what you want.
    So look at your code again it may be just a few simple things here and there.
    oh just a last note the applet doesnt work properly, it doesnt allow you
    to select any of the squares you want you only have to click certain ones.

    Good luck
    Ako


    "shafi" <shafi100@hotmail.com> wrote:
    >
    >Applet cant be intstantiated
    >
    >help. I have ie 5.5
    >
    >this the code. Fiirst day programming in java.
    >
    >package thegamethree;
    >
    >import java.awt.*;
    >import java.awt.event.*;
    >import java.applet.*;
    >import javax.swing.*;
    >
    >public class tictactoe extends Applet {
    > boolean isStandalone = false;
    > boolean whoturn = true; // True - X False - O
    > boolean enabledbutton[] = new boolean[10];
    > String XorO[] = new String [10];
    >
    >
    > JButton jBtn[] = new JButton[10];
    > JButton jBtn1 = new JButton();
    > JButton jBtn2 = new JButton();
    > JButton jBtn3 = new JButton();
    > JButton jBtn6 = new JButton();
    > JButton jBtn5 = new JButton();
    > JButton jBtn4 = new JButton();
    > JButton jBtn9 = new JButton();
    > JButton jBtn8 = new JButton();
    > JButton jBtn7 = new JButton();
    > JLabel jLabel1 = new JLabel();
    > JLabel jLblwhoturn = new JLabel();
    > /**Get a parameter value*/
    > public String getParameter(String key, String def) {
    > return isStandalone ? System.getProperty(key, def) :
    > (getParameter(key) != null ? getParameter(key) : def);
    > }
    >
    > /**Construct the applet*/
    > public tictactoe() {
    > }
    > /**Initialize the applet*/
    > public void init() {
    >
    > try {
    > jbInit();
    > }
    > catch(Exception e) {
    > e.printStackTrace();
    > }
    > jBtn[1] = jBtn1;
    > jBtn[2] = jBtn2;
    > jBtn[3] = jBtn3;
    > jBtn[4] = jBtn4;
    > jBtn[5] = jBtn5;
    > jBtn[6] = jBtn6;
    > jBtn[7] = jBtn7;
    > jBtn[8] = jBtn8;
    > jBtn[9] = jBtn9;
    > enabledbutton[1] = true;
    > enabledbutton[2] = true;
    > enabledbutton[3] = true;
    > enabledbutton[4] = true;
    > enabledbutton[5] = true;
    > enabledbutton[6] = true;
    > enabledbutton[7] = true;
    > enabledbutton[8] = true;
    > enabledbutton[9] = true;
    > XorO[1] = "f";
    > XorO[2] = "f";
    > XorO[3] = "f";
    > XorO[4] = "f";
    > XorO[5] = "f";
    > XorO[6] = "f";
    > XorO[7] = "f";
    > XorO[8] = "f";
    > XorO[9] = "f";
    >
    > }
    >
    >
    >
    > /**Component initialization*/
    > private void jbInit() throws Exception {
    > this.setLayout(null);
    > jBtn1.setBounds(new Rectangle(79, 58, 74, 80));
    > jBtn1.addMouseListener(new java.awt.event.MouseAdapter() {
    > public void mouseClicked(MouseEvent e) {
    > jBtn1_mouseClicked(e);
    > }
    > });
    > jBtn1.setToolTipText("");
    > jBtn1.setMnemonic('1');
    > jBtn1.setFont(new java.awt.Font("Dialog", 0, 40));
    > jBtn2.setFont(new java.awt.Font("Dialog", 0, 40));
    > jBtn2.setToolTipText("");
    > jBtn2.setMnemonic('2');
    > jBtn2.setBounds(new Rectangle(155, 58, 74, 80));
    > jBtn2.addMouseListener(new java.awt.event.MouseAdapter() {
    > public void mouseClicked(MouseEvent e) {
    > jBtn2_mouseClicked(e);
    > }
    > });
    > jBtn3.setFont(new java.awt.Font("Dialog", 0, 40));
    > jBtn3.setToolTipText("");
    > jBtn3.setMnemonic('9');
    > jBtn3.setBounds(new Rectangle(232, 58, 74, 80));
    > jBtn3.addMouseListener(new java.awt.event.MouseAdapter() {
    > public void mouseClicked(MouseEvent e) {
    > jBtn3_mouseClicked(e);
    > }
    > });
    > jBtn6.setBounds(new Rectangle(231, 139, 74, 80));
    > jBtn6.addMouseListener(new java.awt.event.MouseAdapter() {
    > public void mouseClicked(MouseEvent e) {
    > jBtn6_mouseClicked(e);
    > }
    > });
    > jBtn6.setToolTipText("");
    > jBtn6.setMnemonic('0');
    > jBtn6.setFont(new java.awt.Font("Dialog", 0, 40));
    > jBtn5.addMouseListener(new java.awt.event.MouseAdapter() {
    > public void mouseClicked(MouseEvent e) {
    > jBtn5_mouseClicked(e);
    > }
    > });
    > jBtn5.setBounds(new Rectangle(154, 140, 74, 80));
    > jBtn5.setToolTipText("");
    > jBtn5.setFont(new java.awt.Font("Dialog", 0, 40));
    > jBtn4.setFont(new java.awt.Font("Dialog", 0, 40));
    > jBtn4.setToolTipText("");
    > jBtn4.setBounds(new Rectangle(78, 140, 74, 80));
    > jBtn4.addMouseListener(new java.awt.event.MouseAdapter() {
    > public void mouseClicked(MouseEvent e) {
    > jBtn4_mouseClicked(e);
    > }
    > });
    > jBtn9.setBounds(new Rectangle(231, 221, 74, 80));
    > jBtn9.addMouseListener(new java.awt.event.MouseAdapter() {
    > public void mouseClicked(MouseEvent e) {
    > jBtn9_mouseClicked(e);
    > }
    > });
    > jBtn9.setToolTipText("");
    > jBtn9.setFont(new java.awt.Font("Dialog", 0, 40));
    > jBtn8.addMouseListener(new java.awt.event.MouseAdapter() {
    > public void mouseClicked(MouseEvent e) {
    > jBtn8_mouseClicked(e);
    > }
    > });
    > jBtn8.setBounds(new Rectangle(155, 221, 74, 80));
    > jBtn8.setToolTipText("");
    > jBtn8.setFont(new java.awt.Font("Dialog", 0, 40));
    > jBtn7.setFont(new java.awt.Font("Dialog", 0, 40));
    > jBtn7.setToolTipText("");
    > jBtn7.setBounds(new Rectangle(79, 221, 74, 80));
    > jBtn7.addMouseListener(new java.awt.event.MouseAdapter() {
    > public void mouseClicked(MouseEvent e) {
    > jBtn7_mouseClicked(e);
    > }
    > });
    > jLabel1.setFont(new java.awt.Font("Dialog", 0, 25));
    > jLabel1.setText("TicTacToe made by Shafi");
    > jLabel1.setBounds(new Rectangle(52, 9, 306, 52));
    > jLblwhoturn.setFont(new java.awt.Font("Dialog", 1, 50));
    > jLblwhoturn.setToolTipText("");
    > jLblwhoturn.setText("X - Turn");
    > jLblwhoturn.setBounds(new Rectangle(95, 318, 202, 61));
    > this.setBackground(UIManager.getColor("EditorPane.caretForeground"));
    > this.setForeground(Color.white);
    > this.add(jLabel1, null);
    > this.add(jBtn2, null);
    > this.add(jBtn1, null);
    > this.add(jBtn3, null);
    > this.add(jBtn6, null);
    > this.add(jBtn5, null);
    > this.add(jBtn4, null);
    > this.add(jBtn7, null);
    > this.add(jBtn8, null);
    > this.add(jBtn9, null);
    > this.add(jLblwhoturn, null);
    > }
    > /**Get Applet information*/
    > public String getAppletInfo() {
    > return "Applet Information";
    >
    > }
    > /**Get parameter info*/
    > public String[][] getParameterInfo() {
    > return null;
    > }
    >
    >
    >
    > void jBtn2_mouseClicked(MouseEvent e) {
    > int ix = 2;
    >
    >
    > if (enabledbutton[ix]) {
    > if (whoturn) {
    > jBtn[ix].setText("X");
    > whoturn = false;
    > jLblwhoturn.setText("O - Turn");
    > XorO[ix] = "X";
    > }
    > else {
    > jBtn[ix].setText("O");
    > whoturn = true;
    > jLblwhoturn.setText("X - Turn");
    > XorO[ix] = "O";
    > }
    >
    > jBtn[ix].setEnabled(false);
    > }
    > enabledbutton[ix] = false;
    >
    >
    > //tring sx = "X";
    >
    >
    >
    > if ( ( XorO[1] == "X" & XorO[2] == "X" & XorO[3] == "X")
    > | ( XorO[4] == "X" & XorO[5] == "X" & XorO[6] == "X")
    > | ( XorO[7] == "X" & XorO[8] == "X" & XorO[9] == "X")
    >
    > | ( XorO[1] == "X" & XorO[4] == "X" & XorO[7] == "X")
    > | ( XorO[2] == "X" & XorO[5] == "X" & XorO[8] == "X")
    > | ( XorO[3] == "X" & XorO[6] == "X" & XorO[9] == "X")
    >
    > | ( XorO[1] == "X" & XorO[5] == "X" & XorO[9] == "X")
    > | ( XorO[3] == "X" & XorO[5] == "X" & XorO[7] == "X") )
    >
    > {
    > jLblwhoturn.setText("X - Wins");
    > }
    >
    > if ( ( XorO[1] == "O" & XorO[2] == "O" & XorO[3] == "O")
    > | ( XorO[4] == "O" & XorO[5] == "O" & XorO[6] == "O")
    > | ( XorO[7] == "O" & XorO[8] == "O" & XorO[9] == "O")
    >
    > | ( XorO[1] == "O" & XorO[4] == "O" & XorO[7] == "O")
    > | ( XorO[2] == "O" & XorO[5] == "O" & XorO[8] == "O")
    > | ( XorO[3] == "O" & XorO[6] == "O" & XorO[9] == "O")
    >
    > | ( XorO[1] == "O" & XorO[5] == "O" & XorO[9] == "O")
    > | ( XorO[3] == "O" & XorO[5] == "O" & XorO[7] == "O") )
    >
    > {
    > jLblwhoturn.setText("0 - Wins");
    > }
    >
    > }
    >
    >
    > void jBtn5_mouseClicked(MouseEvent e) {
    > int ix = 5;
    >
    >
    > if (enabledbutton[ix]) {
    > if (whoturn) {
    > jBtn[ix].setText("X");
    > whoturn = false;
    > jLblwhoturn.setText("O - Turn");
    > XorO[ix] = "X";
    > }
    > else {
    > jBtn[ix].setText("O");
    > whoturn = true;
    > jLblwhoturn.setText("X - Turn");
    > XorO[ix] = "O";
    > }
    >
    > jBtn[ix].setEnabled(false);
    > }
    > enabledbutton[ix] = false;
    >
    >
    > if ( ( XorO[1] == "X" & XorO[2] == "X" & XorO[3] == "X")
    > | ( XorO[4] == "X" & XorO[5] == "X" & XorO[6] == "X")
    > | ( XorO[7] == "X" & XorO[8] == "X" & XorO[9] == "X")
    >
    > | ( XorO[1] == "X" & XorO[4] == "X" & XorO[7] == "X")
    > | ( XorO[2] == "X" & XorO[5] == "X" & XorO[8] == "X")
    > | ( XorO[3] == "X" & XorO[6] == "X" & XorO[9] == "X")
    >
    > | ( XorO[1] == "X" & XorO[5] == "X" & XorO[9] == "X")
    > | ( XorO[3] == "X" & XorO[5] == "X" & XorO[7] == "X") )
    >
    > {
    > jLblwhoturn.setText("X - Wins");
    > }
    >
    > if ( ( XorO[1] == "O" & XorO[2] == "O" & XorO[3] == "O")
    > | ( XorO[4] == "O" & XorO[5] == "O" & XorO[6] == "O")
    > | ( XorO[7] == "O" & XorO[8] == "O" & XorO[9] == "O")
    >
    > | ( XorO[1] == "O" & XorO[4] == "O" & XorO[7] == "O")
    > | ( XorO[2] == "O" & XorO[5] == "O" & XorO[8] == "O")
    > | ( XorO[3] == "O" & XorO[6] == "O" & XorO[9] == "O")
    >
    > | ( XorO[1] == "O" & XorO[5] == "O" & XorO[9] == "O")
    > | ( XorO[3] == "O" & XorO[5] == "O" & XorO[7] == "O") )
    >
    > {
    > jLblwhoturn.setText("0 - Wins");
    > }
    >
    >
    >
    >
    > }
    >
    > void jBtn8_mouseClicked(MouseEvent e) {
    > int ix = 8;
    >
    >
    > if (enabledbutton[ix]) {
    > if (whoturn) {
    > jBtn[ix].setText("X");
    > whoturn = false;
    > jLblwhoturn.setText("O - Turn");
    > XorO[ix] = "X";
    > }
    > else {
    > jBtn[ix].setText("O");
    > whoturn = true;
    > jLblwhoturn.setText("X - Turn");
    > XorO[ix] = "O";
    > }
    >
    > jBtn[ix].setEnabled(false);
    > }
    > enabledbutton[ix] = false;
    >
    >
    > if ( ( XorO[1] == "X" & XorO[2] == "X" & XorO[3] == "X")
    > | ( XorO[4] == "X" & XorO[5] == "X" & XorO[6] == "X")
    > | ( XorO[7] == "X" & XorO[8] == "X" & XorO[9] == "X")
    >
    > | ( XorO[1] == "X" & XorO[4] == "X" & XorO[7] == "X")
    > | ( XorO[2] == "X" & XorO[5] == "X" & XorO[8] == "X")
    > | ( XorO[3] == "X" & XorO[6] == "X" & XorO[9] == "X")
    >
    > | ( XorO[1] == "X" & XorO[5] == "X" & XorO[9] == "X")
    > | ( XorO[3] == "X" & XorO[5] == "X" & XorO[7] == "X") )
    >
    > {
    > jLblwhoturn.setText("X - Wins");
    > }
    >
    > if ( ( XorO[1] == "O" & XorO[2] == "O" & XorO[3] == "O")
    > | ( XorO[4] == "O" & XorO[5] == "O" & XorO[6] == "O")
    > | ( XorO[7] == "O" & XorO[8] == "O" & XorO[9] == "O")
    >
    > | ( XorO[1] == "O" & XorO[4] == "O" & XorO[7] == "O")
    > | ( XorO[2] == "O" & XorO[5] == "O" & XorO[8] == "O")
    > | ( XorO[3] == "O" & XorO[6] == "O" & XorO[9] == "O")
    >
    > | ( XorO[1] == "O" & XorO[5] == "O" & XorO[9] == "O")
    > | ( XorO[3] == "O" & XorO[5] == "O" & XorO[7] == "O") )
    >
    > {
    > jLblwhoturn.setText("0 - Wins");
    > }
    >
    >
    > }
    >
    > void jBtn1_mouseClicked(MouseEvent e) {
    > int ix = 1;
    >
    >
    > if (enabledbutton[ix]) {
    > if (whoturn) {
    > jBtn[ix].setText("X");
    > whoturn = false;
    > jLblwhoturn.setText("O - Turn");
    > XorO[ix] = "X";
    > }
    > else {
    > jBtn[ix].setText("O");
    > whoturn = true;
    > jLblwhoturn.setText("X - Turn");
    > XorO[ix] = "O";
    > }
    >
    > jBtn[ix].setEnabled(false);
    > }
    > enabledbutton[ix] = false;
    >
    >
    > if ( ( XorO[1] == "X" & XorO[2] == "X" & XorO[3] == "X")
    > | ( XorO[4] == "X" & XorO[5] == "X" & XorO[6] == "X")
    > | ( XorO[7] == "X" & XorO[8] == "X" & XorO[9] == "X")
    >
    > | ( XorO[1] == "X" & XorO[4] == "X" & XorO[7] == "X")
    > | ( XorO[2] == "X" & XorO[5] == "X" & XorO[8] == "X")
    > | ( XorO[3] == "X" & XorO[6] == "X" & XorO[9] == "X")
    >
    > | ( XorO[1] == "X" & XorO[5] == "X" & XorO[9] == "X")
    > | ( XorO[3] == "X" & XorO[5] == "X" & XorO[7] == "X") )
    >
    > {
    > jLblwhoturn.setText("X - Wins");
    > }
    >
    > if ( ( XorO[1] == "O" & XorO[2] == "O" & XorO[3] == "O")
    > | ( XorO[4] == "O" & XorO[5] == "O" & XorO[6] == "O")
    > | ( XorO[7] == "O" & XorO[8] == "O" & XorO[9] == "O")
    >
    > | ( XorO[1] == "O" & XorO[4] == "O" & XorO[7] == "O")
    > | ( XorO[2] == "O" & XorO[5] == "O" & XorO[8] == "O")
    > | ( XorO[3] == "O" & XorO[6] == "O" & XorO[9] == "O")
    >
    > | ( XorO[1] == "O" & XorO[5] == "O" & XorO[9] == "O")
    > | ( XorO[3] == "O" & XorO[5] == "O" & XorO[7] == "O") )
    >
    > {
    > jLblwhoturn.setText("0 - Wins");
    > }
    >
    >
    >
    > }
    >
    > void jBtn3_mouseClicked(MouseEvent e) {
    > int ix = 3;
    >
    >
    > if (enabledbutton[ix]) {
    > if (whoturn) {
    > jBtn[ix].setText("X");
    > whoturn = false;
    > jLblwhoturn.setText("O - Turn");
    > XorO[ix] = "X";
    > }
    > else {
    > jBtn[ix].setText("O");
    > whoturn = true;
    > jLblwhoturn.setText("X - Turn");
    > XorO[ix] = "O";
    > }
    >
    > jBtn[ix].setEnabled(false);
    > }
    > enabledbutton[ix] = false;
    >
    >
    > if ( ( XorO[1] == "X" & XorO[2] == "X" & XorO[3] == "X")
    > | ( XorO[4] == "X" & XorO[5] == "X" & XorO[6] == "X")
    > | ( XorO[7] == "X" & XorO[8] == "X" & XorO[9] == "X")
    >
    > | ( XorO[1] == "X" & XorO[4] == "X" & XorO[7] == "X")
    > | ( XorO[2] == "X" & XorO[5] == "X" & XorO[8] == "X")
    > | ( XorO[3] == "X" & XorO[6] == "X" & XorO[9] == "X")
    >
    > | ( XorO[1] == "X" & XorO[5] == "X" & XorO[9] == "X")
    > | ( XorO[3] == "X" & XorO[5] == "X" & XorO[7] == "X") )
    >
    > {
    > jLblwhoturn.setText("X - Wins");
    > }
    >
    > if ( ( XorO[1] == "O" & XorO[2] == "O" & XorO[3] == "O")
    > | ( XorO[4] == "O" & XorO[5] == "O" & XorO[6] == "O")
    > | ( XorO[7] == "O" & XorO[8] == "O" & XorO[9] == "O")
    >
    > | ( XorO[1] == "O" & XorO[4] == "O" & XorO[7] == "O")
    > | ( XorO[2] == "O" & XorO[5] == "O" & XorO[8] == "O")
    > | ( XorO[3] == "O" & XorO[6] == "O" & XorO[9] == "O")
    >
    > | ( XorO[1] == "O" & XorO[5] == "O" & XorO[9] == "O")
    > | ( XorO[3] == "O" & XorO[5] == "O" & XorO[7] == "O") )
    >
    > {
    > jLblwhoturn.setText("0 - Wins");
    > }
    >
    > }
    >
    > void jBtn4_mouseClicked(MouseEvent e) {
    > int ix = 4;
    >
    >
    > if (enabledbutton[ix]) {
    > if (whoturn) {
    > jBtn[ix].setText("X");
    > whoturn = false;
    > jLblwhoturn.setText("O - Turn");
    > XorO[ix] = "X";
    > }
    > else {
    > jBtn[ix].setText("O");
    > whoturn = true;
    > jLblwhoturn.setText("X - Turn");
    > XorO[ix] = "O";
    > }
    >
    > jBtn[ix].setEnabled(false);
    > }
    > enabledbutton[ix] = false;
    >
    > if ( ( XorO[1] == "X" & XorO[2] == "X" & XorO[3] == "X")
    > | ( XorO[4] == "X" & XorO[5] == "X" & XorO[6] == "X")
    > | ( XorO[7] == "X" & XorO[8] == "X" & XorO[9] == "X")
    >
    > | ( XorO[1] == "X" & XorO[4] == "X" & XorO[7] == "X")
    > | ( XorO[2] == "X" & XorO[5] == "X" & XorO[8] == "X")
    > | ( XorO[3] == "X" & XorO[6] == "X" & XorO[9] == "X")
    >
    > | ( XorO[1] == "X" & XorO[5] == "X" & XorO[9] == "X")
    > | ( XorO[3] == "X" & XorO[5] == "X" & XorO[7] == "X") )
    >
    > {
    > jLblwhoturn.setText("X - Wins");
    > }
    >
    > if ( ( XorO[1] == "O" & XorO[2] == "O" & XorO[3] == "O")
    > | ( XorO[4] == "O" & XorO[5] == "O" & XorO[6] == "O")
    > | ( XorO[7] == "O" & XorO[8] == "O" & XorO[9] == "O")
    >
    > | ( XorO[1] == "O" & XorO[4] == "O" & XorO[7] == "O")
    > | ( XorO[2] == "O" & XorO[5] == "O" & XorO[8] == "O")
    > | ( XorO[3] == "O" & XorO[6] == "O" & XorO[9] == "O")
    >
    > | ( XorO[1] == "O" & XorO[5] == "O" & XorO[9] == "O")
    > | ( XorO[3] == "O" & XorO[5] == "O" & XorO[7] == "O") )
    >
    > {
    > jLblwhoturn.setText("0 - Wins");
    > }
    >
    > }
    >
    > void jBtn6_mouseClicked(MouseEvent e) {
    > int ix = 6;
    >
    >
    > if (enabledbutton[ix]) {
    > if (whoturn) {
    > jBtn[ix].setText("X");
    > whoturn = false;
    > jLblwhoturn.setText("O - Turn");
    > XorO[ix] = "X";
    > }
    > else {
    > jBtn[ix].setText("O");
    > whoturn = true;
    > jLblwhoturn.setText("X - Turn");
    > XorO[ix] = "O";
    > }
    >
    > jBtn[ix].setEnabled(false);
    > }
    > enabledbutton[ix] = false;
    >
    > if ( ( XorO[1] == "X" & XorO[2] == "X" & XorO[3] == "X")
    > | ( XorO[4] == "X" & XorO[5] == "X" & XorO[6] == "X")
    > | ( XorO[7] == "X" & XorO[8] == "X" & XorO[9] == "X")
    >
    > | ( XorO[1] == "X" & XorO[4] == "X" & XorO[7] == "X")
    > | ( XorO[2] == "X" & XorO[5] == "X" & XorO[8] == "X")
    > | ( XorO[3] == "X" & XorO[6] == "X" & XorO[9] == "X")
    >
    > | ( XorO[1] == "X" & XorO[5] == "X" & XorO[9] == "X")
    > | ( XorO[3] == "X" & XorO[5] == "X" & XorO[7] == "X") )
    >
    > {
    > jLblwhoturn.setText("X - Wins");
    > }
    >
    > if ( ( XorO[1] == "O" & XorO[2] == "O" & XorO[3] == "O")
    > | ( XorO[4] == "O" & XorO[5] == "O" & XorO[6] == "O")
    > | ( XorO[7] == "O" & XorO[8] == "O" & XorO[9] == "O")
    >
    > | ( XorO[1] == "O" & XorO[4] == "O" & XorO[7] == "O")
    > | ( XorO[2] == "O" & XorO[5] == "O" & XorO[8] == "O")
    > | ( XorO[3] == "O" & XorO[6] == "O" & XorO[9] == "O")
    >
    > | ( XorO[1] == "O" & XorO[5] == "O" & XorO[9] == "O")
    > | ( XorO[3] == "O" & XorO[5] == "O" & XorO[7] == "O") )
    >
    > {
    > jLblwhoturn.setText("0 - Wins");
    > }
    >
    > }
    >
    > void jBtn7_mouseClicked(MouseEvent e) {
    > int ix = 7;
    >
    >
    > if (enabledbutton[ix]) {
    > if (whoturn) {
    > jBtn[ix].setText("X");
    > whoturn = false;
    > jLblwhoturn.setText("O - Turn");
    > XorO[ix] = "X";
    > }
    > else {
    > jBtn[ix].setText("O");
    > whoturn = true;
    > jLblwhoturn.setText("X - Turn");
    > XorO[ix] = "O";
    > }
    >
    > jBtn[ix].setEnabled(false);
    > }
    > enabledbutton[ix] = false;
    > if ( ( XorO[1] == "X" & XorO[2] == "X" & XorO[3] == "X")
    > | ( XorO[4] == "X" & XorO[5] == "X" & XorO[6] == "X")
    > | ( XorO[7] == "X" & XorO[8] == "X" & XorO[9] == "X")
    >
    > | ( XorO[1] == "X" & XorO[4] == "X" & XorO[7] == "X")
    > | ( XorO[2] == "X" & XorO[5] == "X" & XorO[8] == "X")
    > | ( XorO[3] == "X" & XorO[6] == "X" & XorO[9] == "X")
    >
    > | ( XorO[1] == "X" & XorO[5] == "X" & XorO[9] == "X")
    > | ( XorO[3] == "X" & XorO[5] == "X" & XorO[7] == "X") )
    >
    > {
    > jLblwhoturn.setText("X - Wins");
    > }
    >
    > if ( ( XorO[1] == "O" & XorO[2] == "O" & XorO[3] == "O")
    > | ( XorO[4] == "O" & XorO[5] == "O" & XorO[6] == "O")
    > | ( XorO[7] == "O" & XorO[8] == "O" & XorO[9] == "O")
    >
    > | ( XorO[1] == "O" & XorO[4] == "O" & XorO[7] == "O")
    > | ( XorO[2] == "O" & XorO[5] == "O" & XorO[8] == "O")
    > | ( XorO[3] == "O" & XorO[6] == "O" & XorO[9] == "O")
    >
    > | ( XorO[1] == "O" & XorO[5] == "O" & XorO[9] == "O")
    > | ( XorO[3] == "O" & XorO[5] == "O" & XorO[7] == "O") )
    >
    > {
    > jLblwhoturn.setText("0 - Wins");
    > }
    >
    >
    > }
    >
    > void jBtn9_mouseClicked(MouseEvent e) {
    > int ix = 9;
    >
    >
    > if (enabledbutton[ix]) {
    > if (whoturn) {
    > jBtn[ix].setText("X");
    > whoturn = false;
    > jLblwhoturn.setText("O - Turn");
    > XorO[ix] = "X";
    > }
    > else {
    > jBtn[ix].setText("O");
    > whoturn = true;
    > jLblwhoturn.setText("X - Turn");
    > XorO[ix] = "O";
    > }
    >
    > jBtn[ix].setEnabled(false);
    > }
    > enabledbutton[ix] = false;
    >
    > if ( ( XorO[1] == "X" & XorO[2] == "X" & XorO[3] == "X")
    > | ( XorO[4] == "X" & XorO[5] == "X" & XorO[6] == "X")
    > | ( XorO[7] == "X" & XorO[8] == "X" & XorO[9] == "X")
    >
    > | ( XorO[1] == "X" & XorO[4] == "X" & XorO[7] == "X")
    > | ( XorO[2] == "X" & XorO[5] == "X" & XorO[8] == "X")
    > | ( XorO[3] == "X" & XorO[6] == "X" & XorO[9] == "X")
    >
    > | ( XorO[1] == "X" & XorO[5] == "X" & XorO[9] == "X")
    > | ( XorO[3] == "X" & XorO[5] == "X" & XorO[7] == "X") )
    >
    > {
    > jLblwhoturn.setText("X - Wins");
    > }
    >
    > if ( ( XorO[1] == "O" & XorO[2] == "O" & XorO[3] == "O")
    > | ( XorO[4] == "O" & XorO[5] == "O" & XorO[6] == "O")
    > | ( XorO[7] == "O" & XorO[8] == "O" & XorO[9] == "O")
    >
    > | ( XorO[1] == "O" & XorO[4] == "O" & XorO[7] == "O")
    > | ( XorO[2] == "O" & XorO[5] == "O" & XorO[8] == "O")
    > | ( XorO[3] == "O" & XorO[6] == "O" & XorO[9] == "O")
    >
    > | ( XorO[1] == "O" & XorO[5] == "O" & XorO[9] == "O")
    > | ( XorO[3] == "O" & XorO[5] == "O" & XorO[7] == "O") )
    >
    > {
    > jLblwhoturn.setText("0 - Wins");
    > }
    >
    > }
    >}
    >
    >



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center