Iseng-iseng saya mencari cara membuat game tictactoe sebagai tugas yang diberikan dosen, ternyata source codenya sudah tertampang di halaman web dosen yang memberikan tugas tersebut. dihalaman tersebut sudah terpampang sebuah applet game tictactoe menggunakan java. Otomatis untuk menampilkan applet dibrowser, dibutuhkan file.class yang merpuakan hasil kompilasi file.java. Nah entah lupa khilaf atau kesalahan sistem, bapak "Pemberi tugas" tidak menutup akses tempat disimpannya file .class tersebut.
Tentu saja mahasiswa seperti saya tidak bisa mengabaikan source code gratis dari dosen ini, langsung saja saya dowload TicTac.class dan di decompile menggunakan aplikasi java decompiler. Jreeeng Seluruh source code dari dosen terpampang jelas dengan sempurna. Namun source code dibawah ini bukanlah buatan dosen saya, melainkan robor pembuat game tictactoe yang telah dibuat olehnya. Iniah dia source code game TacTicToe Dengan java Applet
/*--------------------------------------------------------*/
/*-----Author : Robot Dosen saya------------------------*/
/*-----Program: Applet Tictactoe--------------------------*/
/*------------http://go-program.blogspot.com--------------*/
/*--------------------------------------------------------*/
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JApplet;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
public class TicTac extends JApplet
implements ActionListener
{
int x = 10;
JButton[] pp = new JButton[this.x * this.x];
JLabel ln = new JLabel(" Giliran Pemain Pertama");
int w = 1;
public void init() {
setSize(50 * this.x + 5, 50 * this.x + 5);
JPanel pane = new JPanel();
BorderLayout border = new BorderLayout();
pane.setLayout(border);
JPanel paneButton = new JPanel();
paneButton.setLayout(new GridLayout(this.x, this.x, 0, 0));
for (int i = 0; i < this.x * this.x; i++) this.pp[i] = new JButton("");
for (int i = 0; i < this.x * this.x; i++) this.pp[i].addActionListener(this);
for (int i = 0; i < this.x * this.x; i++) paneButton.add(this.pp[i]);
pane.add("Center", paneButton);
pane.add("South", add(this.ln));
setContentPane(pane);
show();
}
public void actionPerformed(ActionEvent evt) {
if (evt.getSource() == this.pp[0]) {
if (this.w == 1) { this.pp[0].setText(" X "); this.pp[0].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[0].setText(" O "); this.pp[0].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[0].setEnabled(false);
} else if (evt.getSource() == this.pp[1]) {
if (this.w == 1) { this.pp[1].setText(" X "); this.pp[1].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[1].setText(" O "); this.pp[1].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[1].setEnabled(false);
} else if (evt.getSource() == this.pp[2]) {
if (this.w == 1) { this.pp[2].setText(" X "); this.pp[2].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[2].setText(" O "); this.pp[2].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[2].setEnabled(false);
} else if (evt.getSource() == this.pp[3]) {
if (this.w == 1) { this.pp[3].setText(" X "); this.pp[3].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[3].setText(" O "); this.pp[3].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[3].setEnabled(false);
} else if (evt.getSource() == this.pp[4]) {
if (this.w == 1) { this.pp[4].setText(" X "); this.pp[4].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[4].setText(" O "); this.pp[4].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[4].setEnabled(false);
} else if (evt.getSource() == this.pp[5]) {
if (this.w == 1) { this.pp[5].setText(" X "); this.pp[5].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[5].setText(" O "); this.pp[5].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[5].setEnabled(false);
} else if (evt.getSource() == this.pp[6]) {
if (this.w == 1) { this.pp[6].setText(" X "); this.pp[6].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[6].setText(" O "); this.pp[6].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[6].setEnabled(false);
} else if (evt.getSource() == this.pp[7]) {
if (this.w == 1) { this.pp[7].setText(" X "); this.pp[7].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[7].setText(" O "); this.pp[7].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[7].setEnabled(false);
} else if (evt.getSource() == this.pp[8]) {
if (this.w == 1) { this.pp[8].setText(" X "); this.pp[8].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[8].setText(" O "); this.pp[8].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[8].setEnabled(false);
} else if (evt.getSource() == this.pp[9]) {
if (this.w == 1) { this.pp[9].setText(" X "); this.pp[9].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[9].setText(" O "); this.pp[9].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[9].setEnabled(false);
} else if (evt.getSource() == this.pp[10]) {
if (this.w == 1) { this.pp[10].setText(" X "); this.pp[10].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[10].setText(" O "); this.pp[10].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[10].setEnabled(false);
} else if (evt.getSource() == this.pp[11]) {
if (this.w == 1) { this.pp[11].setText(" X "); this.pp[11].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[11].setText(" O "); this.pp[11].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[11].setEnabled(false);
} else if (evt.getSource() == this.pp[12]) {
if (this.w == 1) { this.pp[12].setText(" X "); this.pp[12].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[12].setText(" O "); this.pp[12].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[12].setEnabled(false);
} else if (evt.getSource() == this.pp[13]) {
if (this.w == 1) { this.pp[13].setText(" X "); this.pp[13].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[13].setText(" O "); this.pp[13].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[13].setEnabled(false);
} else if (evt.getSource() == this.pp[14]) {
if (this.w == 1) { this.pp[14].setText(" X "); this.pp[14].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[14].setText(" O "); this.pp[14].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[14].setEnabled(false);
} else if (evt.getSource() == this.pp[15]) {
if (this.w == 1) { this.pp[15].setText(" X "); this.pp[15].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[15].setText(" O "); this.pp[15].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[15].setEnabled(false);
} else if (evt.getSource() == this.pp[16]) {
if (this.w == 1) { this.pp[16].setText(" X "); this.pp[16].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[16].setText(" O "); this.pp[16].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[16].setEnabled(false);
} else if (evt.getSource() == this.pp[17]) {
if (this.w == 1) { this.pp[17].setText(" X "); this.pp[17].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[17].setText(" O "); this.pp[17].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[17].setEnabled(false);
} else if (evt.getSource() == this.pp[18]) {
if (this.w == 1) { this.pp[18].setText(" X "); this.pp[18].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[18].setText(" O "); this.pp[18].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[18].setEnabled(false);
} else if (evt.getSource() == this.pp[19]) {
if (this.w == 1) { this.pp[19].setText(" X "); this.pp[19].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[19].setText(" O "); this.pp[19].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[19].setEnabled(false);
} else if (evt.getSource() == this.pp[20]) {
if (this.w == 1) { this.pp[20].setText(" X "); this.pp[20].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[20].setText(" O "); this.pp[20].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[20].setEnabled(false);
} else if (evt.getSource() == this.pp[21]) {
if (this.w == 1) { this.pp[21].setText(" X "); this.pp[21].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[21].setText(" O "); this.pp[21].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[21].setEnabled(false);
} else if (evt.getSource() == this.pp[22]) {
if (this.w == 1) { this.pp[22].setText(" X "); this.pp[22].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[22].setText(" O "); this.pp[22].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[22].setEnabled(false);
} else if (evt.getSource() == this.pp[23]) {
if (this.w == 1) { this.pp[23].setText(" X "); this.pp[23].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[23].setText(" O "); this.pp[23].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[23].setEnabled(false);
} else if (evt.getSource() == this.pp[24]) {
if (this.w == 1) { this.pp[24].setText(" X "); this.pp[24].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[24].setText(" O "); this.pp[24].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[24].setEnabled(false);
} else if (evt.getSource() == this.pp[25]) {
if (this.w == 1) { this.pp[25].setText(" X "); this.pp[25].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[25].setText(" O "); this.pp[25].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[25].setEnabled(false);
} else if (evt.getSource() == this.pp[26]) {
if (this.w == 1) { this.pp[26].setText(" X "); this.pp[26].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[26].setText(" O "); this.pp[26].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[26].setEnabled(false);
} else if (evt.getSource() == this.pp[27]) {
if (this.w == 1) { this.pp[27].setText(" X "); this.pp[27].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[27].setText(" O "); this.pp[27].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[27].setEnabled(false);
} else if (evt.getSource() == this.pp[28]) {
if (this.w == 1) { this.pp[28].setText(" X "); this.pp[28].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[28].setText(" O "); this.pp[28].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[28].setEnabled(false);
} else if (evt.getSource() == this.pp[29]) {
if (this.w == 1) { this.pp[29].setText(" X "); this.pp[29].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[29].setText(" O "); this.pp[29].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[29].setEnabled(false);
} else if (evt.getSource() == this.pp[30]) {
if (this.w == 1) { this.pp[30].setText(" X "); this.pp[30].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[30].setText(" O "); this.pp[30].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[30].setEnabled(false);
} else if (evt.getSource() == this.pp[31]) {
if (this.w == 1) { this.pp[31].setText(" X "); this.pp[31].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[31].setText(" O "); this.pp[31].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[31].setEnabled(false);
} else if (evt.getSource() == this.pp[32]) {
if (this.w == 1) { this.pp[32].setText(" X "); this.pp[32].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[32].setText(" O "); this.pp[32].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[32].setEnabled(false);
} else if (evt.getSource() == this.pp[33]) {
if (this.w == 1) { this.pp[33].setText(" X "); this.pp[33].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[33].setText(" O "); this.pp[33].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[33].setEnabled(false);
} else if (evt.getSource() == this.pp[34]) {
if (this.w == 1) { this.pp[34].setText(" X "); this.pp[34].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[34].setText(" O "); this.pp[34].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[34].setEnabled(false);
} else if (evt.getSource() == this.pp[35]) {
if (this.w == 1) { this.pp[35].setText(" X "); this.pp[35].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[35].setText(" O "); this.pp[35].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[35].setEnabled(false);
} else if (evt.getSource() == this.pp[36]) {
if (this.w == 1) { this.pp[36].setText(" X "); this.pp[36].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[36].setText(" O "); this.pp[36].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[36].setEnabled(false);
} else if (evt.getSource() == this.pp[37]) {
if (this.w == 1) { this.pp[37].setText(" X "); this.pp[37].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[37].setText(" O "); this.pp[37].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[37].setEnabled(false);
} else if (evt.getSource() == this.pp[38]) {
if (this.w == 1) { this.pp[38].setText(" X "); this.pp[38].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[38].setText(" O "); this.pp[38].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[38].setEnabled(false);
} else if (evt.getSource() == this.pp[39]) {
if (this.w == 1) { this.pp[39].setText(" X "); this.pp[39].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[39].setText(" O "); this.pp[39].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[39].setEnabled(false);
} else if (evt.getSource() == this.pp[40]) {
if (this.w == 1) { this.pp[40].setText(" X "); this.pp[40].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[40].setText(" O "); this.pp[40].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[40].setEnabled(false);
} else if (evt.getSource() == this.pp[41]) {
if (this.w == 1) { this.pp[41].setText(" X "); this.pp[41].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[41].setText(" O "); this.pp[41].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[41].setEnabled(false);
} else if (evt.getSource() == this.pp[42]) {
if (this.w == 1) { this.pp[42].setText(" X "); this.pp[42].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[42].setText(" O "); this.pp[42].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[42].setEnabled(false);
} else if (evt.getSource() == this.pp[43]) {
if (this.w == 1) { this.pp[43].setText(" X "); this.pp[43].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[43].setText(" O "); this.pp[43].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[43].setEnabled(false);
} else if (evt.getSource() == this.pp[44]) {
if (this.w == 1) { this.pp[44].setText(" X "); this.pp[44].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[44].setText(" O "); this.pp[44].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[44].setEnabled(false);
} else if (evt.getSource() == this.pp[45]) {
if (this.w == 1) { this.pp[45].setText(" X "); this.pp[45].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[45].setText(" O "); this.pp[45].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[45].setEnabled(false);
} else if (evt.getSource() == this.pp[46]) {
if (this.w == 1) { this.pp[46].setText(" X "); this.pp[46].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[46].setText(" O "); this.pp[46].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[46].setEnabled(false);
} else if (evt.getSource() == this.pp[47]) {
if (this.w == 1) { this.pp[47].setText(" X "); this.pp[47].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[47].setText(" O "); this.pp[47].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[47].setEnabled(false);
} else if (evt.getSource() == this.pp[48]) {
if (this.w == 1) { this.pp[48].setText(" X "); this.pp[48].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[48].setText(" O "); this.pp[48].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[48].setEnabled(false);
} else if (evt.getSource() == this.pp[49]) {
if (this.w == 1) { this.pp[49].setText(" X "); this.pp[49].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[49].setText(" O "); this.pp[49].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[49].setEnabled(false);
} else if (evt.getSource() == this.pp[50]) {
if (this.w == 1) { this.pp[50].setText(" X "); this.pp[50].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[50].setText(" O "); this.pp[50].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[50].setEnabled(false);
} else if (evt.getSource() == this.pp[51]) {
if (this.w == 1) { this.pp[51].setText(" X "); this.pp[51].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[51].setText(" O "); this.pp[51].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[51].setEnabled(false);
} else if (evt.getSource() == this.pp[52]) {
if (this.w == 1) { this.pp[52].setText(" X "); this.pp[52].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[52].setText(" O "); this.pp[52].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[52].setEnabled(false);
} else if (evt.getSource() == this.pp[53]) {
if (this.w == 1) { this.pp[53].setText(" X "); this.pp[53].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[53].setText(" O "); this.pp[53].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[53].setEnabled(false);
} else if (evt.getSource() == this.pp[54]) {
if (this.w == 1) { this.pp[54].setText(" X "); this.pp[54].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[54].setText(" O "); this.pp[54].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[54].setEnabled(false);
} else if (evt.getSource() == this.pp[55]) {
if (this.w == 1) { this.pp[55].setText(" X "); this.pp[55].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[55].setText(" O "); this.pp[55].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[55].setEnabled(false);
} else if (evt.getSource() == this.pp[56]) {
if (this.w == 1) { this.pp[56].setText(" X "); this.pp[56].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[56].setText(" O "); this.pp[56].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[56].setEnabled(false);
} else if (evt.getSource() == this.pp[57]) {
if (this.w == 1) { this.pp[57].setText(" X "); this.pp[57].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[57].setText(" O "); this.pp[57].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[57].setEnabled(false);
} else if (evt.getSource() == this.pp[58]) {
if (this.w == 1) { this.pp[58].setText(" X "); this.pp[58].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[58].setText(" O "); this.pp[58].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[58].setEnabled(false);
} else if (evt.getSource() == this.pp[59]) {
if (this.w == 1) { this.pp[59].setText(" X "); this.pp[59].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[59].setText(" O "); this.pp[59].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[59].setEnabled(false);
} else if (evt.getSource() == this.pp[60]) {
if (this.w == 1) { this.pp[60].setText(" X "); this.pp[60].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[60].setText(" O "); this.pp[60].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[60].setEnabled(false);
} else if (evt.getSource() == this.pp[61]) {
if (this.w == 1) { this.pp[61].setText(" X "); this.pp[61].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[61].setText(" O "); this.pp[61].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[61].setEnabled(false);
} else if (evt.getSource() == this.pp[62]) {
if (this.w == 1) { this.pp[62].setText(" X "); this.pp[62].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[62].setText(" O "); this.pp[62].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[62].setEnabled(false);
} else if (evt.getSource() == this.pp[63]) {
if (this.w == 1) { this.pp[63].setText(" X "); this.pp[63].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[63].setText(" O "); this.pp[63].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[63].setEnabled(false);
} else if (evt.getSource() == this.pp[64]) {
if (this.w == 1) { this.pp[64].setText(" X "); this.pp[64].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[64].setText(" O "); this.pp[64].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[64].setEnabled(false);
} else if (evt.getSource() == this.pp[65]) {
if (this.w == 1) { this.pp[65].setText(" X "); this.pp[65].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[65].setText(" O "); this.pp[65].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[65].setEnabled(false);
} else if (evt.getSource() == this.pp[66]) {
if (this.w == 1) { this.pp[66].setText(" X "); this.pp[66].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[66].setText(" O "); this.pp[66].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[66].setEnabled(false);
} else if (evt.getSource() == this.pp[67]) {
if (this.w == 1) { this.pp[67].setText(" X "); this.pp[67].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[67].setText(" O "); this.pp[67].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[67].setEnabled(false);
} else if (evt.getSource() == this.pp[68]) {
if (this.w == 1) { this.pp[68].setText(" X "); this.pp[68].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[68].setText(" O "); this.pp[68].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[68].setEnabled(false);
} else if (evt.getSource() == this.pp[69]) {
if (this.w == 1) { this.pp[69].setText(" X "); this.pp[69].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[69].setText(" O "); this.pp[69].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[69].setEnabled(false);
} else if (evt.getSource() == this.pp[70]) {
if (this.w == 1) { this.pp[70].setText(" X "); this.pp[70].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[70].setText(" O "); this.pp[70].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[70].setEnabled(false);
} else if (evt.getSource() == this.pp[71]) {
if (this.w == 1) { this.pp[71].setText(" X "); this.pp[71].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[71].setText(" O "); this.pp[71].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[71].setEnabled(false);
} else if (evt.getSource() == this.pp[72]) {
if (this.w == 1) { this.pp[72].setText(" X "); this.pp[72].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[72].setText(" O "); this.pp[72].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[72].setEnabled(false);
} else if (evt.getSource() == this.pp[73]) {
if (this.w == 1) { this.pp[73].setText(" X "); this.pp[73].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[73].setText(" O "); this.pp[73].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[73].setEnabled(false);
} else if (evt.getSource() == this.pp[74]) {
if (this.w == 1) { this.pp[74].setText(" X "); this.pp[74].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[74].setText(" O "); this.pp[74].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[74].setEnabled(false);
} else if (evt.getSource() == this.pp[75]) {
if (this.w == 1) { this.pp[75].setText(" X "); this.pp[75].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[75].setText(" O "); this.pp[75].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[75].setEnabled(false);
} else if (evt.getSource() == this.pp[76]) {
if (this.w == 1) { this.pp[76].setText(" X "); this.pp[76].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[76].setText(" O "); this.pp[76].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[76].setEnabled(false);
} else if (evt.getSource() == this.pp[77]) {
if (this.w == 1) { this.pp[77].setText(" X "); this.pp[77].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[77].setText(" O "); this.pp[77].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[77].setEnabled(false);
} else if (evt.getSource() == this.pp[78]) {
if (this.w == 1) { this.pp[78].setText(" X "); this.pp[78].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[78].setText(" O "); this.pp[78].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[78].setEnabled(false);
} else if (evt.getSource() == this.pp[79]) {
if (this.w == 1) { this.pp[79].setText(" X "); this.pp[79].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[79].setText(" O "); this.pp[79].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[79].setEnabled(false);
} else if (evt.getSource() == this.pp[80]) {
if (this.w == 1) { this.pp[80].setText(" X "); this.pp[80].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[80].setText(" O "); this.pp[80].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[80].setEnabled(false);
} else if (evt.getSource() == this.pp[81]) {
if (this.w == 1) { this.pp[81].setText(" X "); this.pp[81].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[81].setText(" O "); this.pp[81].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[81].setEnabled(false);
} else if (evt.getSource() == this.pp[82]) {
if (this.w == 1) { this.pp[82].setText(" X "); this.pp[82].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[82].setText(" O "); this.pp[82].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[82].setEnabled(false);
} else if (evt.getSource() == this.pp[83]) {
if (this.w == 1) { this.pp[83].setText(" X "); this.pp[83].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[83].setText(" O "); this.pp[83].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[83].setEnabled(false);
} else if (evt.getSource() == this.pp[84]) {
if (this.w == 1) { this.pp[84].setText(" X "); this.pp[84].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[84].setText(" O "); this.pp[84].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[84].setEnabled(false);
} else if (evt.getSource() == this.pp[85]) {
if (this.w == 1) { this.pp[85].setText(" X "); this.pp[85].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[85].setText(" O "); this.pp[85].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[85].setEnabled(false);
} else if (evt.getSource() == this.pp[86]) {
if (this.w == 1) { this.pp[86].setText(" X "); this.pp[86].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[86].setText(" O "); this.pp[86].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[86].setEnabled(false);
} else if (evt.getSource() == this.pp[87]) {
if (this.w == 1) { this.pp[87].setText(" X "); this.pp[87].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[87].setText(" O "); this.pp[87].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[87].setEnabled(false);
} else if (evt.getSource() == this.pp[88]) {
if (this.w == 1) { this.pp[88].setText(" X "); this.pp[88].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[88].setText(" O "); this.pp[88].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[88].setEnabled(false);
} else if (evt.getSource() == this.pp[89]) {
if (this.w == 1) { this.pp[89].setText(" X "); this.pp[89].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[89].setText(" O "); this.pp[89].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[89].setEnabled(false);
} else if (evt.getSource() == this.pp[90]) {
if (this.w == 1) { this.pp[90].setText(" X "); this.pp[90].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[90].setText(" O "); this.pp[90].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[90].setEnabled(false);
} else if (evt.getSource() == this.pp[91]) {
if (this.w == 1) { this.pp[91].setText(" X "); this.pp[91].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[91].setText(" O "); this.pp[91].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[91].setEnabled(false);
} else if (evt.getSource() == this.pp[92]) {
if (this.w == 1) { this.pp[92].setText(" X "); this.pp[92].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[92].setText(" O "); this.pp[92].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[92].setEnabled(false);
} else if (evt.getSource() == this.pp[93]) {
if (this.w == 1) { this.pp[93].setText(" X "); this.pp[93].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[93].setText(" O "); this.pp[93].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[93].setEnabled(false);
} else if (evt.getSource() == this.pp[94]) {
if (this.w == 1) { this.pp[94].setText(" X "); this.pp[94].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[94].setText(" O "); this.pp[94].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[94].setEnabled(false);
} else if (evt.getSource() == this.pp[95]) {
if (this.w == 1) { this.pp[95].setText(" X "); this.pp[95].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[95].setText(" O "); this.pp[95].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[95].setEnabled(false);
} else if (evt.getSource() == this.pp[96]) {
if (this.w == 1) { this.pp[96].setText(" X "); this.pp[96].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[96].setText(" O "); this.pp[96].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[96].setEnabled(false);
} else if (evt.getSource() == this.pp[97]) {
if (this.w == 1) { this.pp[97].setText(" X "); this.pp[97].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[97].setText(" O "); this.pp[97].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[97].setEnabled(false);
} else if (evt.getSource() == this.pp[98]) {
if (this.w == 1) { this.pp[98].setText(" X "); this.pp[98].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[98].setText(" O "); this.pp[98].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[98].setEnabled(false);
} else if (evt.getSource() == this.pp[99]) {
if (this.w == 1) { this.pp[99].setText(" X "); this.pp[99].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[99].setText(" O "); this.pp[99].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[99].setEnabled(false);
} else if (evt.getSource() == this.pp[100]) {
if (this.w == 1) { this.pp[100].setText(" X "); this.pp[100].setBackground(Color.green); this.ln.setText(" Giliran Pemain Kedua"); this.w = 0; } else {
this.pp[100].setText(" O "); this.pp[100].setBackground(Color.yellow); this.ln.setText(" Giliran Pemain Pertama"); this.w = 1;
}this.pp[100].setEnabled(false);
}
}
}
Source codenya Agak panjang ya, udah panjang namun fiturnya masih belum keren. Belum ada sistem kemenangan, Sehingga hanya untuk asal asal klik saja tanpa ada aturan menang. Untuk melihat atau jika anda ingin memainkannya, dapat menuju ke: http://cs.unsyiah.ac.id/~alamri/belajar/TicTac/ (KLIK)
Karena kurang puas, akhirnya tetap saja saya tidak menggunakan source code ini untuk mengumpulkan tugas. Tapi tetap saja googling dan mencari pencerahan. Entar source code game TicTacToe saya, akan diposting pada artikel selanjutnya. Semoga pembahasan kali ini bisa berguna ya.. :)
Post a Comment