All source code in Java/ Javascript Ask a Java/ Javascript Pro Discussion Forum Categories All jobs in Java/ Javascript
playing,game
   Code/Articles � |  Newest/Best � |  Community � |  Jobs � |  Other � |  Goto � | 
CategoriesSearch Newest CodeCoding ContestCode of the DayAsk A ProJobsUpload
Java/ Javascript Stats

 Code: 485,651. lines
 Jobs: 197. postings

 How to support the site

 
Sponsored by:
Quick Search for:  in language:    
You are in:
 
Login





Latest postings for Java/ Javascript.
Click here to see a screenshot of this code!automated glossary 2010 beta psychology 200 forced learning and memory restorer! rodlewis2010 beta!
By ROD LEWIS on 3/7

(Screen Shot)

Mouseover_3Imag e_Fader_Nav
By Mark Acuna on 3/7


Click here to see a screenshot of this code!NLabs' Folder Tree Generator
By nagesh borate on 2/28

(Screen Shot)

AI-TicTacToe
By Masood Fallahpoor on 3/4


Click here to see a screenshot of this code!Function
By Mr. SNMP Simamora on 3/4

(Screen Shot)

Click here to see a screenshot of this code!Median Number
By Mr. SNMP Simamora on 3/4

(Screen Shot)

Click here to see a screenshot of this code!Simple ppt viewer
By Rio Purwanggono on 3/3

(Screen Shot)

Click here to see a screenshot of this code!rain or snow your name or anything you want rod lewis2010 BETA
By ROD LEWIS on 3/1

(Screen Shot)

Click here to see a screenshot of this code!Simple jQuery Slideshow
By Bardhyl on 2/27

(Screen Shot)

Click here to see a screenshot of this code!Java JDBC Connection with SQL Server using Jtds Driver
By Nor Samsiah Sani on 2/24

(Screen Shot)

Click here to see a screenshot of this code!The Web Browser
By snowboardr on 2/24

(Screen Shot)

Click here to see a screenshot of this code!Font special effects filter for Adobe photo's + flash, dreamweaver MS editors beta producer 2010
By ROD LEWIS on 2/22

(Screen Shot)

Click here to see a screenshot of this code!new year
By highfinddale on 2/21

(Screen Shot)

Convex Hull
By Atishay Jain on 2/21


Click here to see a screenshot of this code!Java Upload Applet With Resume Facility
By Amit Kumar Gaur on 2/11

(Screen Shot)

Click here to put this ticker on your site!


Add this ticker to your desktop!


Daily Code Email
To join the 'Code of the Day' Mailing List click here!



 
 
   

xo

Print
Email
 
VB icon
Submitted on: 1/28/2010 8:41:59 AM
By: ahmed wagih 
Level: Intermediate
User Rating: Unrated
Compatibility:Java (JDK 1.1), Java (JDK 1.2), Java (JDK 1.3), Java (JDK 1.4), Java (JDK 1.5)

Users have accessed this code 870 times.
 
 
     playing x o game
 
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
 
Terms of Agreement:   
By using this code, you agree to the following terms...   
1) You may use this code in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.   
2) You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
3) You may link to this code from another website, but ONLY if it is not wrapped in a frame. 
4) You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.

//**************************************
//     
// Name: xo
// Description:playing x o game
// By: ahmed wagih
//
//This code is copyrighted and has// limited warranties.Please see http://
//     www.Planet-Source-Code.com/vb/scripts/Sh
//     owCode.asp?txtCodeId=6568&lngWId=2//for details.//**************************************
//     

import java.awt.Color;
import javax.swing.JOptionPane;
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/*
* XO.java
*
* Created on Jan 24, 2010, 9:59:30 PM
*/
/**
*
* @author WIGO
*/


    public class XO extends javax.swing.JFrame {
    int x=1; //determines el Turns player 1 aw 2
    int z=1;
    void drawzz()


        {if(z==9){
        button1.setLabel("");
        button2.setLabel("");
        button3.setLabel("");
        button4.setLabel("");
        button5.setLabel("");
        button6.setLabel("");
        button7.setLabel("");
        button8.setLabel("");
        button9.setLabel("");
        JOptionPane.showMessageDialog(null, "draw");
    }}

void checko () // bet7aded elO hateksab wla la2 { if(((button1.getLabel().equals("O")))&&((button2.getLabel().equals("O")))&&((button3.getLabel().equals("O")))) { button1.setBackground(Color.red); button2.setBackground(Color.red); button3.setBackground(Color.red); JOptionPane.showMessageDialog(null, "2ndPlayer WIN"); button1.setLabel(""); button2.setLabel(""); button3.setLabel(""); button4.setLabel(""); button5.setLabel(""); button6.setLabel(""); button7.setLabel(""); button8.setLabel(""); button9.setLabel(""); button1.setBackground(Color.black); button2.setBackground(Color.black); button3.setBackground(Color.black); }
if(((button4.getLabel().equals("O")))&&((button5.getLabel().equals("O")))&&((button6.getLabel().equals("O")))) { button4.setBackground(Color.red); button5.setBackground(Color.red); button6.setBackground(Color.red); JOptionPane.showMessageDialog(null, "2ndPlayer WIN"); button1.setLabel(""); button2.setLabel(""); button3.setLabel(""); button4.setLabel(""); button5.setLabel(""); button6.setLabel(""); button7.setLabel(""); button8.setLabel(""); button9.setLabel("");textField2.setText((textField2.getText())+"l"); button1.setLabel(""); button2.setLabel(""); button3.setLabel(""); button4.setLabel(""); button5.setLabel(""); button6.setLabel(""); button7.setLabel(""); button8.setLabel(""); button9.setLabel("");textField2.setText((textField2.getText())+"l"); button4.setBackground(Color.black); button5.setBackground(Color.black); button6.setBackground(Color.black); }
if(((button7.getLabel().equals("O")))&&((button8.getLabel().equals("O")))&&((button9.getLabel().equals("O")))) { button7.setBackground(Color.red); button8.setBackground(Color.red); button9.setBackground(Color.red); JOptionPane.showMessageDialog(null, "2ndPlayer WIN"); button1.setLabel(""); button2.setLabel(""); button3.setLabel(""); button4.setLabel(""); button5.setLabel(""); button6.setLabel(""); button7.setLabel(""); button8.setLabel(""); button9.setLabel("");textField2.setText((textField2.getText())+"l"); button7.setBackground(Color.black); button8.setBackground(Color.black); button9.setBackground(Color.black); }
if(((button1.getLabel().equals("O")))&&((button4.getLabel().equals("O")))&&((button7.getLabel().equals("O")))) { button1.setBackground(Color.red); button4.setBackground(Color.red); button7.setBackground(Color.red); JOptionPane.showMessageDialog(null, "2ndPlayer WIN"); button1.setLabel(""); button2.setLabel(""); button3.setLabel(""); button4.setLabel(""); button5.setLabel(""); button6.setLabel(""); button7.setLabel(""); button8.setLabel(""); button9.setLabel("");textField2.setText((textField2.getText())+"l"); button1.setBackground(Color.black); button4.setBackground(Color.black); button7.setBackground(Color.black);} if(((button2.getLabel().equals("O")))&&((button5.getLabel().equals("O")))&&((button8.getLabel().equals("O")))) { button2.setBackground(Color.red); button5.setBackground(Color.red); button8.setBackground(Color.red); JOptionPane.showMessageDialog(null, "2ndPlayer WIN"); button1.setLabel(""); button2.setLabel(""); button3.setLabel(""); button4.setLabel(""); button5.setLabel(""); button6.setLabel(""); button7.setLabel(""); button8.setLabel(""); button9.setLabel("");textField2.setText((textField2.getText())+"l"); button2.setBackground(Color.black); button5.setBackground(Color.black); button8.setBackground(Color.black);} if(((button3.getLabel().equals("O")))&&((button9.getLabel().equals("O")))&&((button6.getLabel().equals("O")))) { button9.setBackground(Color.red); button6.setBackground(Color.red); button3.setBackground(Color.red); JOptionPane.showMessageDialog(null, "2ndPlayer WIN"); button1.setLabel(""); button2.setLabel(""); button3.setLabel(""); button4.setLabel(""); button5.setLabel(""); button6.setLabel(""); button7.setLabel(""); button8.setLabel(""); button9.setLabel("");textField2.setText((textField2.getText())+"l"); button9.setBackground(Color.black); button6.setBackground(Color.black); button3.setBackground(Color.black); } if(((button1.getLabel().equals("O")))&&((button5.getLabel().equals("O")))&&((button9.getLabel().equals("O")))) { button1.setBackground(Color.red); button5.setBackground(Color.red); button9.setBackground(Color.red); JOptionPane.showMessageDialog(null, "2ndPlayer WIN"); button1.setLabel(""); button2.setLabel(""); button3.setLabel(""); button4.setLabel(""); button5.setLabel(""); button6.setLabel(""); button7.setLabel(""); button8.setLabel(""); button9.setLabel("");textField2.setText((textField2.getText())+"l"); button1.setBackground(Color.black); button5.setBackground(Color.black); button9.setBackground(Color.black);} if(((button5.getLabel().equals("O")))&&((button7.getLabel().equals("O")))&&((button3.getLabel().equals("O")))) { button7.setBackground(Color.red); button5.setBackground(Color.red); button3.setBackground(Color.red); JOptionPane.showMessageDialog(null, "2ndPlayer WIN"); button1.setLabel(""); button2.setLabel(""); button3.setLabel(""); button4.setLabel(""); button5.setLabel(""); button6.setLabel(""); button7.setLabel(""); button8.setLabel(""); button9.setLabel("");textField2.setText((textField2.getText())+"l"); button7.setBackground(Color.black); button5.setBackground(Color.black); button3.setBackground(Color.black);} }
void check () { if(((button1.getLabel().equals("X")))&&((button2.getLabel().equals("X")))&&((button3.getLabel().equals("X")))) { button1.setBackground(Color.red); button2.setBackground(Color.red); button3.setBackground(Color.red); JOptionPane.showMessageDialog(null, "1stPlayer WIN"); button1.setLabel(""); button2.setLabel(""); button3.setLabel(""); button4.setLabel(""); button5.setLabel(""); button6.setLabel(""); button7.setLabel(""); button8.setLabel(""); button9.setLabel("");textField1.setText((textField1.getText())+"l"); button1.setBackground(Color.black); button2.setBackground(Color.black); button3.setBackground(Color.black);} if(((button4.getLabel().equals("X")))&&((button5.getLabel().equals("X")))&&((button6.getLabel().equals("X")))) { button4.setBackground(Color.red); button5.setBackground(Color.red); button6.setBackground(Color.red); JOptionPane.showMessageDialog(null, "1stPlayer WIN"); button1.setLabel(""); button2.setLabel(""); button3.setLabel(""); button4.setLabel(""); button5.setLabel(""); button6.setLabel(""); button7.setLabel(""); button8.setLabel(""); button9.setLabel("");textField1.setText((textField1.getText())+"l"); button4.setBackground(Color.black); button5.setBackground(Color.black); button6.setBackground(Color.black);} if(((button7.getLabel().equals("X")))&&((button8.getLabel().equals("X")))&&((button9.getLabel().equals("X")))) { button7.setBackground(Color.red); button8.setBackground(Color.red); button9.setBackground(Color.red); JOptionPane.showMessageDialog(null, "1stPlayer WIN"); button1.setLabel(""); button2.setLabel(""); button3.setLabel(""); button4.setLabel(""); button5.setLabel(""); button6.setLabel(""); button7.setLabel(""); button8.setLabel(""); button9.setLabel("");textField1.setText((textField1.getText())+"l"); button7.setBackground(Color.black); button8.setBackground(Color.black); button9.setBackground(Color.black);} if(((button1.getLabel().equals("X")))&&((button4.getLabel().equals("X")))&&((button7.getLabel().equals("X")))) { button1.setBackground(Color.red); button4.setBackground(Color.red); button7.setBackground(Color.red); JOptionPane.showMessageDialog(null, "1stPlayer WIN"); button1.setLabel(""); button2.setLabel(""); button3.setLabel(""); button4.setLabel(""); button5.setLabel(""); button6.setLabel(""); button7.setLabel(""); button8.setLabel(""); button9.setLabel("");textField1.setText((textField1.getText())+"l"); button1.setBackground(Color.black); button4.setBackground(Color.black); button7.setBackground(Color.black);} if(((button2.getLabel().equals("X")))&&((button5.getLabel().equals("X")))&&((button8.getLabel().equals("X")))) { button2.setBackground(Color.red); button5.setBackground(Color.red); button8.setBackground(Color.red); JOptionPane.showMessageDialog(null, "1stPlayer WIN"); button1.setLabel(""); button2.setLabel(""); button3.setLabel(""); button4.setLabel(""); button5.setLabel(""); button6.setLabel(""); button7.setLabel(""); button8.setLabel(""); button9.setLabel("");textField1.setText((textField1.getText())+"l"); button2.setBackground(Color.black); button5.setBackground(Color.black); button8.setBackground(Color.black);} if(((button3.getLabel().equals("X")))&&((button9.getLabel().equals("X")))&&((button6.getLabel().equals("X")))) { button9.setBackground(Color.red); button6.setBackground(Color.red); button3.setBackground(Color.red); JOptionPane.showMessageDialog(null, "1stPlayer WIN"); button1.setLabel(""); button2.setLabel(""); button3.setLabel(""); button4.setLabel(""); button5.setLabel(""); button6.setLabel(""); button7.setLabel(""); button8.setLabel(""); button9.setLabel("");textField1.setText((textField1.getText())+"l"); button9.setBackground(Color.black); button6.setBackground(Color.black); button3.setBackground(Color.black); } if(((button1.getLabel().equals("X")))&&((button5.getLabel().equals("X")))&&((button9.getLabel().equals("X")))) { button1.setBackground(Color.red); button5.setBackground(Color.red); button9.setBackground(Color.red); JOptionPane.showMessageDialog(null, "1stPlayer WIN"); button1.setLabel(""); button2.setLabel(""); button3.setLabel(""); button4.setLabel(""); button5.setLabel(""); button6.setLabel(""); button7.setLabel(""); button8.setLabel(""); button9.setLabel("");textField1.setText((textField1.getText())+"l"); button1.setBackground(Color.black); button5.setBackground(Color.black); button9.setBackground(Color.black); } if(((button5.getLabel().equals("X")))&&((button7.getLabel().equals("X")))&&((button3.getLabel().equals("X")))) { button7.setBackground(Color.red); button5.setBackground(Color.red); button3.setBackground(Color.red); JOptionPane.showMessageDialog(null, "1stPlayer WIN"); button1.setLabel(""); button2.setLabel(""); button3.setLabel(""); button4.setLabel(""); button5.setLabel(""); button6.setLabel(""); button7.setLabel(""); button8.setLabel(""); button9.setLabel("");textField1.setText((textField1.getText())+"l"); button7.setBackground(Color.black); button5.setBackground(Color.black); button3.setBackground(Color.black); }}
/** Creates new form XO */ public XO() { initComponents(); }
/** this method is called from within the constructor to * initialize the form. * WARNING: do NOT modify this code. The content of this method is * always regenerated by the Form Editor. */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collaps // ed" desc="Generated Code">//GEN-BEGIN // :initComponents private void initComponents() { button10 = new java.awt.Button(); button1 = new java.awt.Button(); button2 = new java.awt.Button(); button3 = new java.awt.Button(); button4 = new java.awt.Button(); button5 = new java.awt.Button(); button6 = new java.awt.Button(); button7 = new java.awt.Button(); button8 = new java.awt.Button(); button9 = new java.awt.Button(); label1 = new java.awt.Label(); label2 = new java.awt.Label(); textField1 = new java.awt.TextField(); textField2 = new java.awt.TextField(); button10.setLabel("button10"); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); button1.setBackground(new java.awt.Color(0, 0, 0)); button1.setFont(new java.awt.Font("Dialog", 0, 48)); // NOI18N button1.setForeground(new java.awt.Color(255, 255, 255)); button1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { button1ActionPerformed(evt); }
});
button2.setBackground(new java.awt.Color(0, 0, 0)); button2.setFont(new java.awt.Font("Dialog", 0, 48)); // NOI18N button2.setForeground(new java.awt.Color(255, 255, 255)); button2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { button2ActionPerformed(evt); }
});
button3.setBackground(new java.awt.Color(0, 0, 0)); button3.setFont(new java.awt.Font("Dialog", 0, 48)); // NOI18N button3.setForeground(new java.awt.Color(255, 255, 255)); button3.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { button3ActionPerformed(evt); }
});
button4.setBackground(new java.awt.Color(0, 0, 0)); button4.setFont(new java.awt.Font("Dialog", 0, 48)); // NOI18N button4.setForeground(new java.awt.Color(255, 255, 255)); button4.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { button4ActionPerformed(evt); }
});
button5.setBackground(new java.awt.Color(0, 0, 0)); button5.setFont(new java.awt.Font("Dialog", 0, 48)); // NOI18N button5.setForeground(new java.awt.Color(255, 255, 255)); button5.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { button5ActionPerformed(evt); }
});
button6.setBackground(new java.awt.Color(0, 0, 0)); button6.setFont(new java.awt.Font("Dialog", 0, 48)); // NOI18N button6.setForeground(new java.awt.Color(255, 255, 255)); button6.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { button6ActionPerformed(evt); }
});
button7.setBackground(new java.awt.Color(0, 0, 0)); button7.setFont(new java.awt.Font("Dialog", 0, 48)); // NOI18N button7.setForeground(new java.awt.Color(255, 255, 255)); button7.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { button7ActionPerformed(evt); }
});
button8.setBackground(new java.awt.Color(0, 0, 0)); button8.setFont(new java.awt.Font("Dialog", 0, 48)); // NOI18N button8.setForeground(new java.awt.Color(255, 255, 255)); button8.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { button8ActionPerformed(evt); }
});
button9.setBackground(new java.awt.Color(0, 0, 0)); button9.setFont(new java.awt.Font("Dialog", 0, 48)); // NOI18N button9.setForeground(new java.awt.Color(255, 255, 255)); button9.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { button9ActionPerformed(evt); }
});
label1.setText("Player 1"); label2.setText("Player 2"); textField1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { textField1ActionPerformed(evt); }
});
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addContainerGap() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addComponent(button1, javax.swing.GroupLayout.PREFERRED_SIZE, 87, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(button2, javax.swing.GroupLayout.PREFERRED_SIZE, 87, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(button3, javax.swing.GroupLayout.PREFERRED_SIZE, 87, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(button7, javax.swing.GroupLayout.PREFERRED_SIZE, 87, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(button4, javax.swing.GroupLayout.PREFERRED_SIZE, 87, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addGroup(layout.createSequentialGroup() .addComponent(button8, javax.swing.GroupLayout.PREFERRED_SIZE, 87, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(button9, javax.swing.GroupLayout.PREFERRED_SIZE, 87, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(layout.createSequentialGroup() .addComponent(button5, javax.swing.GroupLayout.PREFERRED_SIZE, 87, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(button6, javax.swing.GroupLayout.PREFERRED_SIZE, 87, javax.swing.GroupLayout.PREFERRED_SIZE))))) .addGap(24, 24, 24) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(label1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(textField1, javax.swing.GroupLayout.PREFERRED_SIZE, 58, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(24, 24, 24) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(label2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(textField2, javax.swing.GroupLayout.PREFERRED_SIZE, 63, javax.swing.GroupLayout.PREFERRED_SIZE)) .addContainerGap(36, Short.MAX_VALUE)) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGap(57, 57, 57) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addComponent(button2, javax.swing.GroupLayout.PREFERRED_SIZE, 75, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(button1, javax.swing.GroupLayout.PREFERRED_SIZE, 75, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(button3, javax.swing.GroupLayout.PREFERRED_SIZE, 75, javax.swing.GroupLayout.PREFERRED_SIZE))) .addGroup(layout.createSequentialGroup() .addGap(71, 71, 71) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addComponent(label2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(label1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(textField2, javax.swing.GroupLayout.DEFAULT_SIZE, 31, Short.MAX_VALUE) .addComponent(textField1, javax.swing.GroupLayout.DEFAULT_SIZE, 31, Short.MAX_VALUE)))) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(button5, javax.swing.GroupLayout.PREFERRED_SIZE, 75, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(button4, javax.swing.GroupLayout.PREFERRED_SIZE, 75, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(button6, javax.swing.GroupLayout.PREFERRED_SIZE, 75, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(button7, javax.swing.GroupLayout.PREFERRED_SIZE, 75, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(button9, javax.swing.GroupLayout.PREFERRED_SIZE, 75, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(button8, javax.swing.GroupLayout.PREFERRED_SIZE, 75, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(38, 38, 38)) ); pack(); }// </editor-fold>//GEN-END:initComponents
private void button1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_button1ActionPerformed if(button1.getLabel().equals("")){ z++; if(x==1) { x=2; button1.setLabel("X"); z++; }
else { z++;x=1; button1.setLabel("O");}} check(); checko();drawzz(); }//GEN-LAST:event_button1ActionPerformed
private void button2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_button2ActionPerformed if(button2.getLabel().equals("")){ z=z+1; if(x==1) { x=2; button2.setLabel("X"); }
else { x=1; button2.setLabel("O");}check();checko();drawzz(); }
}//GEN-LAST:event_button2ActionPerformed
private void button3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_button3ActionPerformed if(button3.getLabel().equals("")){ z=z+1; if(x==1) { x=2; button3.setLabel("X"); }
else { x=1; button3.setLabel("O");}check();checko();drawzz();} }//GEN-LAST:event_button3ActionPerformed
private void button4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_button4ActionPerformed if(button4.getLabel().equals("")){z=z+1; if(x==1) { x=2; button4.setLabel("X"); }
else { x=1; button4.setLabel("O");}check();checko();drawzz();} }//GEN-LAST:event_button4ActionPerformed
private void button5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_button5ActionPerformed if(button5.getLabel().equals("")){z=z+1; if(x==1) { x=2; button5.setLabel("X"); }
else { x=1; button5.setLabel("O");}check();checko();drawzz();} }//GEN-LAST:event_button5ActionPerformed
private void button6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_button6ActionPerformed if(button6.getLabel().equals("")){ z=z+1;if(x==1) { x=2; button6.setLabel("X"); }
else { x=1; button6.setLabel("O");}check();checko();drawzz();} }//GEN-LAST:event_button6ActionPerformed
private void button7ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_button7ActionPerformed if(button7.getLabel().equals("")){z=z+1; if(x==1) { x=2; button7.setLabel("X"); }
else { x=1; button7.setLabel("O");}check();checko();drawzz();} }//GEN-LAST:event_button7ActionPerformed
private void button8ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_button8ActionPerformed if(button8.getLabel().equals("")){z=z+1; if(x==1) { x=2; button8.setLabel("X"); }
else { x=1; button8.setLabel("O");}check();checko();drawzz();} }//GEN-LAST:event_button8ActionPerformed
private void button9ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_button9ActionPerformed if(button9.getLabel().equals("")){ z=z+1; if(x==1) { x=2; button9.setLabel("X"); }
else { x=1; button9.setLabel("O");}check();checko();drawzz();} }//GEN-LAST:event_button9ActionPerformed
private void textField1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_textField1ActionPerformed // TODO add your handling code here: }//GEN-LAST:event_textField1ActionPerformed
/** * @param args the command line arguments */ public static void main(String args[]) { java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new XO().setVisible(true); }
});
}
// Variables declaration - do not modify //GEN-BEGIN:variables private java.awt.Button button1; private java.awt.Button button10; private java.awt.Button button2; private java.awt.Button button3; private java.awt.Button button4; private java.awt.Button button5; private java.awt.Button button6; private java.awt.Button button7; private java.awt.Button button8; private java.awt.Button button9; private java.awt.Label label1; private java.awt.Label label2; private java.awt.TextField textField1; private java.awt.TextField textField2; // End of variables declaration//GEN-END // :variables }

 
 Report Bad Submission
Use this form to notify us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:
 
Your Vote!

What do you think of this code(in the Intermediate category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor See Voting Log
 
Other User Comments

 There are no comments on this submission.
 
Add Your Feedback!
Note:Not only will your feedback be posted, but an email will be sent to the code's author from the email account you registered on the site, so you can correspond directly.

NOTICE: The author of this code has been kind enough to share it with you.  If you have a criticism, please state it politely or it will be deleted.

For feedback not related to this particular code, please click here.
 
To post feedback, first please login.


 

Categories | Articles and Tutorials | Advanced Search | Recommended Reading | Upload | Newest Code | Code of the Month | Code of the Day | All Time Hall of Fame | Coding Contest | Search for a job | Post a Job | Ask a Pro Discussion Forum | Live Chat | Games | Feedback | Customize | Java/ Javascript Home | Site Home | Other Sites | Open Letter from Moderators | About the Site | Feedback | Link to the Site | Awards | Advertising | Privacy

Copyright� 1997-2010 by Exhedra Solutions, Inc. All Rights Reserved.  By using this site you agree to its Terms and Conditions.   Java and all Java-based marks are trademarks or registered trademarks of Sun Microsystems, Inc. in the U.S. and other countries. Exhedra solutions has no affiliation with Sun Microsystems, Inc.. Planet Source Code (tm) and the phrase "Dream It. Code It" (tm) are trademarks of Exhedra Solutions, Inc.