if(PlayerOneTurn % 2 == 0)
{
if("disable".equals(actionEvent.getActionCommand()))
{
for some reason this chunk of my code is never read. outputs: click one: http://ift.tt/1TB09IU click two: http://ift.tt/22pLRuS third click works (using input) and then the fourth doesn't and so on. i would put the entirety of the code here, but it's too long, so here's some pertinent info:
import javax.swing.*;
import java.awt.Dimension;
import java.awt.event.*;
import java.util.Scanner;
public class SuperTicTacToe implements ActionListener
{
public static String input;
public static String input2;
final static String LABEL_TEXT = "Player One's Turn";
final static String LABEL_TEXT2 = "Player Two's Turn";
JFrame frame;
JPanel contentPane;
JLabel label;
JButton a, a1, a2, a3, a4, a5, a6, a7, a8, a9, b, b1, b2, b3, b4, b5, b6, b7, b8, b9, c, c1, c2, c3, c4,
c5, c6, c7, c8, c9, d, d1, d2, d3, d4, d5, d6, d7, d8, d9, e, e1, e2, e3, e4, e5, e6, e7, e8, e9,
f, f1, f2, f3, f4, f5, f6, f7, f8, f9, g, g1, g2, g3, g4, g5, g6, g7, g8, g9, h, h1, h2, h3, h4, h5,
h6, h7, h8, h9, i, i1, i2, i3, i4, i5, i6, i7, i8, i9;
int PlayerOneTurn = 0;
this is a chunk of code that works:
public void actionPerformed(ActionEvent actionEvent)
{
PlayerOneTurn += 1;
System.out.println(PlayerOneTurn);
Object source = actionEvent.getSource();
if(PlayerOneTurn % 2 != 0)
{
if("disable".equals(actionEvent.getActionCommand()))
{
note the part of this that is exactly the same as the not working part (which is also in the action performed method).
Aucun commentaire:
Enregistrer un commentaire