Jogo da Velha

Achei um tutorial de Jogo da Velha com um metodo deprecated (JFrame.show()).
Toda vez que os jogadores clicam, era para ser desenhado um X ou 0, dependendo de quem é a vez, o problema é que isso não ocorre…

Segue o código:

[code]import javax.swing.;
import java.awt.GridLayout;
import java.awt.event.
;
import java.awt.Graphics;
public class Tabuleiro implements ActionListener
{
private JFrame janela;
private GridLayout layout;
private JButton[][] celulas;
private ImageIcon xis;
private ImageIcon zero;
private String atual;
private boolean fimDeJogo=false;
private int posX;
private int posY;

public Tabuleiro()
{
	setScreen();
	
}

public void setScreen()
{
	janela = new JFrame("");//cria uma nova janela.
	janela.setLocation(posX,posY);//coloca-a na posição x,y; Esta é 0,0 na primeira rodada, 
								  //mas depois guarda a posição final usada pelo usuário
								  //caso ele mova a janela.
	xis = new ImageIcon("xis.png");//carrega o ícone
	zero= new ImageIcon("zero.png");
	atual="";
	atual+="X";
	janela.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	janela.setVisible(true);
	layout = new GridLayout(3,3);
								//O gerenciador de layout das janelas as colocara em colunas e linhas
	janela.setTitle("PancaVelha. Jogador: "+atual);//título da janela.
	janela.setLayout(layout);
	setButtons();
	for(int i =0;i< 3; i++)
	{
		for(int j=0;j<3;j++)
		{
			janela.add(celulas[i][j]);
		}
	}
	janela.setSize(300,300);
	janela.show();//atualiza o desenho da janela.
	fimDeJogo=false;
	
}

public void setButtons()
{
	celulas = new JButton[3][3];
	for(int i =0;i< 3; i++)
	{
		for(int j=0;j<3;j++)
		{
			//Instancia os botões.
			celulas[i][j] = new JButton("");
			celulas[i][j].addActionListener(this);
		}
	}
}

public void resetGame()
{	
	for(int i =0;i< 3; i++)
	{
		for(int j=0;j<3;j++)
		{
			/*
			 *Reseta-se o Status dos botões que representam as células.
			 */
			celulas[i][j].setIcon(null);
			celulas[i][j].addActionListener(this);
			celulas[i][j].revalidate();
		}
	}
	fimDeJogo=false;
}

public void actionPerformed(ActionEvent e)
{
	/*
	 *Este método é chamado automaticamente pelo gerenciador de eventos.
	 *Verificará quem (o que) chamou o evento; como são todos botões, 
	 *o qual chamou o evento terá seu ícone alterado pela imagem que 
	 *representa a jogada atual (X OU 0).
	 */
	for(int i =0;i< 3; i++)
	{
		for(int j=0;j<3;j++)
		{
			if(e.getSource().equals(celulas[i][j]))
			{
				if(atual.compareToIgnoreCase("X")==0)
					celulas[i][j].setIcon(xis);
				else
					celulas[i][j].setIcon(zero);
				celulas[i][j].removeActionListener(this);//para nao ser mais alterada, caso
					//clicada.
				
				String vencedor="";
				//Verifica se teve algum ganhador.
				if((vencedor=calcLinha())!=null)
				{
					JOptionPane.showMessageDialog(null,"O vencedor é "+vencedor);
					fimDeJogo=true;
				//	break;
				}
				vencedor="";
				if((vencedor=calcColuna())!=null)
				{
					JOptionPane.showMessageDialog(null,"O vencedor é "+vencedor);
					fimDeJogo=true;
				//	break;
				}
				vencedor="";
				if((vencedor=calcDiagonais())!=null)
				{
					JOptionPane.showMessageDialog(null,"O vencedor é "+vencedor);
					fimDeJogo=true;
				//	break;
				}
				if( (empate()) && (vencedor==null))
				{
					JOptionPane.showMessageDialog(null,"EMPATE!");
					fimDeJogo=true;
				}
					
				
			}
			if(fimDeJogo)
			{
				newGame();
				break;
			}
		}
	}
	proximaJogada();
}

public void proximaJogada()
{
	/*
	 *Indica quem será o próximo a jogar.
	 */
	if(atual.compareToIgnoreCase("X")==0)
	{
		atual="";
		atual+="O";
	}
	else
	{
		atual="";
		atual+="X";
	}
	janela.setTitle("PancaVelha. Jogador: "+atual);
		
}

public boolean compCell(int c11,int c12,int c21, int c22)
{
	/*
	 *Compara duas células.
	 */
	if( (celulas[c11][c12].getIcon()!=null) && (celulas[c21][c22].getIcon()!=null) )
	{
	
		if(celulas[c11][c12].getIcon().equals(celulas[c21][c22].getIcon()))
		{
			return true;
		}
	}
	return false;
}
public String calcLinha()
{
	/*
	 *Calcula a força bruta se alguma linha foi preenchida.
	 */
	if( (compCell(0,0,0,1)) && (compCell(0,1,0,2)) )
	{
		if(celulas[0][0].getIcon().equals(xis))
			return "x";
		else
			return "0";
	}
	if(	(compCell(1,0,1,1)) && (compCell(1,1,1,2)) )
	{
		if(celulas[1][0].getIcon().equals(xis))
			return "x";
		else
			return "0";
	}
	if	( (compCell(2,0,2,1)) && (compCell(2,1,2,2)) )
	{
		if(celulas[2][0].getIcon().equals(xis))
			return "x";
		else
			return "0";
	}
	return null;
}

public String calcColuna()
{
	/*
	 *Calcula a força bruta se alguma coluna foi preenchida.
	 */
	if( (compCell(0,0,1,0)) && (compCell(1,0,2,0)) )
	{
		if(celulas[0][0].getIcon().equals(xis))
			return "x";
		else
			return "0";
	}
	if(	(compCell(0,1,1,1)) && (compCell(1,1,2,1)) )
	{
		if(celulas[0][1].getIcon().equals(xis))
			return "x";
		else
			return "0";
	}
	if	( (compCell(0,2,1,2)) && (compCell(1,2,2,2)) )
	{
		if(celulas[0][2].getIcon().equals(xis))
			return "x";
		else
			return "0";
	}
	return null;
}

public String calcDiagonais()
{
	/*
	 *Calcula a força bruta se as diagonais completam um jogo.
	 */
	if( (compCell(0,0,1,1)) && (compCell(1,1,2,2)) )
	{
		if(celulas[0][0].getIcon().equals(xis))
			return "x";
		else
			return "0";
	}
	if( (compCell(0,2,1,1)) && (compCell(1,1,2,0)) )
	{
		if(celulas[0][2].getIcon().equals(xis))
			return "x";
		else
			return "0";
	}
	return null;
}

public boolean empate()
{
	/*
	 *Este método será chamado se não houver ganhador (verificado nos métodos anteriores).
	 *Verifica todas células, vendo se existe alguma vazia.
	 */
	boolean tmp=true;
	for(int i =0;i< 3; i++)
	{
		for(int j=0;j<3;j++)
		{
			if(celulas[i][j].getIcon()==null)
				tmp=false;//se tiver alguma que nao foi marcada, ainda nao ocorreu empate.
		}
	}
	return tmp;
}

public boolean acabou()
{
	return fimDeJogo;//verifica se o jogo acabou. Nao utilizado...
}


public void newGame()
{
	/*
	 *Exibe um painel de opção. Cada botao tem um numero, começando do 0. Como o "YES" é o primeiro (esquerda para direita)
	 *seu número é 0. Este número é retornado assim que o botão é pressionado, então se o retorno for 0, um novo jogo começa.
	 */
	if(JOptionPane.showConfirmDialog(null, "Novo jogo?", "Novo", JOptionPane.YES_NO_OPTION, JOptionPane.YES_NO_OPTION, null)==0)
	{
			posX=janela.getX();//guarda a posição da janela, para que outra seja criada na mesma.
			posY=janela.getY();
			janela.setVisible(false);
			janela.disable();
			setScreen();
	}
	else
		System.exit(0);
}

public static void main(String[] args) 
{
	
	Tabuleiro t = new Tabuleiro();
}

}
[/code]

Como eu arrumo isso ?

Muito Obrigado !

Vamos analisar os metodos deprecated (pelo javac -Xlint:deprecation Tabuleiro.java):

Tabuleiro.java:48: warning: [deprecation] show() in java.awt.Window has been deprecated
janela.show();//atualiza o desenho da janela.
^
Tabuleiro.java:294: warning: [deprecation] disable() in java.awt.Component has been deprecated
janela.disable();
^
2 warnings

Visto isso substitui o :

por :

e remove o :

deixa somente :

e verifique se as imagens :

xis = new ImageIcon("xis.jpg");//carrega o ícone
zero= new ImageIcon("zero.png");

estão no diretorio no mesmo diretorio do arquivo fonte.

Fiz essa alterações e funcionou direito não sei se é a melhor forma que estou meio enferrujado no Swing :smiley:

Não funcionou…
Deixei assim:

[code]package jogodavelha;

import javax.swing.;
import java.awt.GridLayout;
import java.awt.event.
;
public class Tabuleiro implements ActionListener
{
private JFrame janela;
private GridLayout layout;
private JButton[][] celulas;
private ImageIcon xis;
private ImageIcon zero;
private String atual;
private boolean fimDeJogo=false;
private int posX;
private int posY;

public Tabuleiro()
{
	setScreen();
}

private void setScreen()
{
	janela = new JFrame("");//cria uma nova janela.
	janela.setLocation(posX,posY);//coloca-a na posi&#65533;&#65533;o x,y; Esta &#65533; 0,0 na primeira rodada, 
								  //mas depois guarda a posi&#65533;&#65533;o final usada pelo usu&#65533;rio
								  //caso ele mova a janela.
	xis = new ImageIcon("xis.png");//carrega o &#65533;cone
	zero= new ImageIcon("zero.png");
	atual="";
	atual+="X";
	janela.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	janela.setVisible(true);
	layout = new GridLayout(3,3);
								//O gerenciador de layout das janelas as colocara em colunas e linhas
	janela.setTitle("Tree-Tac-Toe. Jogador: "+atual);//t&#65533;tulo da janela.
	janela.setLayout(layout);
	setButtons();
	for(int i =0;i< 3; i++)
	{
		for(int j=0;j<3;j++)
		{
			janela.add(celulas[i][j]);
		}
	}
	janela.setSize(300,300);
            janela.setVisible(true);
	fimDeJogo=false;		
}

public void setButtons()
{
	celulas = new JButton[3][3];
	for(int i =0;i< 3; i++)
	{
		for(int j=0;j<3;j++)
		{
			//Instancia os bot&#65533;es.
			celulas[i][j] = new JButton("");
			celulas[i][j].addActionListener(this);
		}
	}
}

public void resetGame()
{	
	for(int i =0;i< 3; i++)
	{
		for(int j=0;j<3;j++)
		{
			/*
			 *Reseta-se o Status dos bot&#65533;es que representam as c&#65533;lulas.
			 */
			celulas[i][j].setIcon(null);
			celulas[i][j].addActionListener(this);
			celulas[i][j].revalidate();
		}
	}
	fimDeJogo=false;
}

public void actionPerformed(ActionEvent e)
{
	/*
	 *Este m&#65533;todo &#65533; chamado automaticamente pelo gerenciador de eventos.
	 *Verificar&#65533; quem (o que) chamou o evento; como s&#65533;o todos bot&#65533;es, 
	 *o qual chamou o evento ter&#65533; seu &#65533;cone alterado pela imagem que 
	 *representa a jogada atual (X OU 0).
	 */
	for(int i =0;i< 3; i++)
	{
		for(int j=0;j<3;j++)
		{
			if(e.getSource().equals(celulas[i][j]))
			{
				if(atual.compareToIgnoreCase("X")==0)
					celulas[i][j].setIcon(xis);
				else
					celulas[i][j].setIcon(zero);
				celulas[i][j].removeActionListener(this);//para nao ser mais alterada, caso
					//clicada.
				
				String vencedor="";
				//Verifica se teve algum ganhador.
				if((vencedor=calcLinha())!=null)
				{
					JOptionPane.showMessageDialog(null,"O vencedor é: "+vencedor);
					fimDeJogo=true;
				//	break;
				}
				vencedor="";
				if((vencedor=calcColuna())!=null)
				{
					JOptionPane.showMessageDialog(null,"O vencedor é: "+vencedor);
					fimDeJogo=true;
				//	break;
				}
				vencedor="";
				if((vencedor=calcDiagonais())!=null)
				{
					JOptionPane.showMessageDialog(null,"O vencedor é: "+vencedor);
					fimDeJogo=true;
				//	break;
				}
				if( (empate()) && (vencedor==null))
				{
					JOptionPane.showMessageDialog(null,"EMPATE!");
					fimDeJogo=true;
				}
					
				
			}
			if(fimDeJogo)
			{
				newGame();
				break;
			}
		}
	}
	proximaJogada();
}

public void proximaJogada()
{
	/*
	 *Indica quem ser&#65533; o pr&#65533;ximo a jogar.
	 */
	if(atual.compareToIgnoreCase("X")==0)
	{
		atual="";
		atual+="O";
	}
	else
	{
		atual="";
		atual+="X";
	}
	janela.setTitle("Tree-Tac-Toe. Jogador: "+atual);
		
}

public boolean compCell(int c11,int c12,int c21, int c22)
{
	/*
	 *Compara duas c&#65533;lulas.
	 */
	if( (celulas[c11][c12].getIcon()!=null) && (celulas[c21][c22].getIcon()!=null) )
	{
	
		if(celulas[c11][c12].getIcon().equals(celulas[c21][c22].getIcon()))
		{
			return true;
		}
	}
	return false;
}
public String calcLinha()
{
	/*
	 *Calcula a for&#65533;a bruta se alguma linha foi preenchida.
	 */
	if( (compCell(0,0,0,1)) && (compCell(0,1,0,2)) )
	{
		if(celulas[0][0].getIcon().equals(xis))
			return "x";
		else
			return "0";
	}
	if(	(compCell(1,0,1,1)) && (compCell(1,1,1,2)) )
	{
		if(celulas[1][0].getIcon().equals(xis))
			return "x";
		else
			return "0";
	}
	if	( (compCell(2,0,2,1)) && (compCell(2,1,2,2)) )
	{
		if(celulas[2][0].getIcon().equals(xis))
			return "x";
		else
			return "0";
	}
	return null;
}

public String calcColuna()
{
	/*
	 *Calcula a for&#65533;a bruta se alguma coluna foi preenchida.
	 */
	if( (compCell(0,0,1,0)) && (compCell(1,0,2,0)) )
	{
		if(celulas[0][0].getIcon().equals(xis))
			return "x";
		else
			return "0";
	}
	if(	(compCell(0,1,1,1)) && (compCell(1,1,2,1)) )
	{
		if(celulas[0][1].getIcon().equals(xis))
			return "x";
		else
			return "0";
	}
	if	( (compCell(0,2,1,2)) && (compCell(1,2,2,2)) )
	{
		if(celulas[0][2].getIcon().equals(xis))
			return "x";
		else
			return "0";
	}
	return null;
}

public String calcDiagonais()
{
	/*
	 *Calcula a for&#65533;a bruta se as diagonais completam um jogo.
	 */
	if( (compCell(0,0,1,1)) && (compCell(1,1,2,2)) )
	{
		if(celulas[0][0].getIcon().equals(xis))
			return "x";
		else
			return "0";
	}
	if( (compCell(0,2,1,1)) && (compCell(1,1,2,0)) )
	{
		if(celulas[0][2].getIcon().equals(xis))
			return "x";
		else
			return "0";
	}
	return null;
}

public boolean empate()
{
	/*
	 *Este m&#65533;todo ser&#65533; chamado se n&#65533;o houver ganhador (verificado nos m&#65533;todos anteriores).
	 *Verifica todas c&#65533;lulas, vendo se existe alguma vazia.
	 */
	boolean tmp=true;
	for(int i =0;i< 3; i++)
	{
		for(int j=0;j<3;j++)
		{
			if(celulas[i][j].getIcon()==null)
				tmp=false;//se tiver alguma que nao foi marcada, ainda nao ocorreu empate.
		}
	}
	return tmp;
}

public boolean acabou()
{
	return fimDeJogo;//verifica se o jogo acabou. Nao utilizado...
}


public void newGame()
{
	/*
	 *Exibe um painel de op&#65533;&#65533;o. Cada botao tem um numero, come&#65533;ando do 0. Como o "YES" &#65533; o primeiro (esquerda para direita)
	 *seu n&#65533;mero &#65533; 0. Este n&#65533;mero &#65533; retornado assim que o bot&#65533;o &#65533; pressionado, ent&#65533;o se o retorno for 0, um novo jogo come&#65533;a.
	 */
	if(JOptionPane.showConfirmDialog(null, "Novo jogo?", "Novo", JOptionPane.YES_NO_OPTION, JOptionPane.YES_NO_OPTION, null)==0)
	{
			posX=janela.getX();//guarda a posi&#65533;&#65533;o da janela, para que outra seja criada na mesma.
			posY=janela.getY();
			janela.setVisible(false);
			janela.dispose();
			setScreen();
	}
	else
		System.exit(0);
}

public static void main(String[] args) 
{
	
	Tabuleiro t = new Tabuleiro();
}

}
[/code]

Meu diretorio:
[URL=http://www.imagebam.com/image/a71a79138294003][/URL]

Lembrando que eu simplesmente fiz um drag-and-drop da img no diretorio no NetBeans !

Vlw e abraço !

Segue o codigo :


import javax.swing.*;
import java.awt.GridLayout;
import java.awt.event.*;
import java.awt.Graphics;
public class Tabuleiro implements ActionListener
{
	private JFrame janela;
	private GridLayout layout;
	private JButton[][] celulas;
	private ImageIcon xis;
	private ImageIcon zero;
	private String atual;
	private boolean fimDeJogo=false;
	private int posX;
	private int posY;

	public Tabuleiro()
	{
		setScreen();

	}

	public void setScreen()
	{
		janela = new JFrame("");//cria uma nova janela.
		janela.setLocation(posX,posY);//coloca-a na posição x,y; Esta é 0,0 na primeira rodada,
									  //mas depois guarda a posição final usada pelo usuário
									  //caso ele mova a janela.
		xis = new ImageIcon("xis.PNG");//carrega o ícone
		zero= new ImageIcon("zero.PNG");
		atual="";
		atual+="X";
		janela.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		janela.setVisible(true);
		layout = new GridLayout(3,3);
									//O gerenciador de layout das janelas as colocara em colunas e linhas
		janela.setTitle("PancaVelha. Jogador: "+atual);//título da janela.
		janela.setLayout(layout);
		setButtons();
		for(int i =0;i< 3; i++)
		{
			for(int j=0;j<3;j++)
			{
				janela.add(celulas[i][j]);
			}
		}
		janela.setSize(300,300);
		janela.setVisible(true);//atualiza o desenho da janela.
		fimDeJogo=false;

	}

	public void setButtons()
	{
		celulas = new JButton[3][3];
		for(int i =0;i< 3; i++)
		{
			for(int j=0;j<3;j++)
			{
				//Instancia os botões.
				celulas[i][j] = new JButton("");
				celulas[i][j].addActionListener(this);
			}
		}
	}

	public void resetGame()
	{
		for(int i =0;i< 3; i++)
		{
			for(int j=0;j<3;j++)
			{
				/*
				 *Reseta-se o Status dos botões que representam as células.
				 */
				celulas[i][j].setIcon(null);
				celulas[i][j].addActionListener(this);
				celulas[i][j].revalidate();
			}
		}
		fimDeJogo=false;
	}

	public void actionPerformed(ActionEvent e)
	{
		/*
		 *Este método é chamado automaticamente pelo gerenciador de eventos.
		 *Verificará quem (o que) chamou o evento; como são todos botões,
		 *o qual chamou o evento terá seu ícone alterado pela imagem que
		 *representa a jogada atual (X OU 0).
		 */
		for(int i =0;i< 3; i++)
		{
			for(int j=0;j<3;j++)
			{
				if(e.getSource().equals(celulas[i][j]))
				{
					if(atual.compareToIgnoreCase("X")==0){
						celulas[i][j].setIcon(xis);
						celulas[i][j].removeActionListener(this);//para nao ser mais alterada, caso
					}else{
						celulas[i][j].setIcon(zero);
					    celulas[i][j].removeActionListener(this);//para nao ser mais alterada, caso
						//clicada.
					}

					String vencedor="";
					//Verifica se teve algum ganhador.
					if((vencedor=calcLinha())!=null)
					{
						JOptionPane.showMessageDialog(null,"O vencedor é "+vencedor);
						fimDeJogo=true;
					//	break;
					}
					vencedor="";
					if((vencedor=calcColuna())!=null)
					{
						JOptionPane.showMessageDialog(null,"O vencedor é "+vencedor);
						fimDeJogo=true;
					//	break;
					}
					vencedor="";
					if((vencedor=calcDiagonais())!=null)
					{
						JOptionPane.showMessageDialog(null,"O vencedor é "+vencedor);
						fimDeJogo=true;
					//	break;
					}
					if( (empate()) && (vencedor==null))
					{
						JOptionPane.showMessageDialog(null,"EMPATE!");
						fimDeJogo=true;
					}


				}
				if(fimDeJogo)
				{
					newGame();
					break;
				}
			}
		}
		proximaJogada();
	}

	public void proximaJogada()
	{
		/*
		 *Indica quem será o próximo a jogar.
		 */
		if(atual.compareToIgnoreCase("X")==0)
		{
			atual="";
			atual+="O";
		}
		else
		{
			atual="";
			atual+="X";
		}
		janela.setTitle("PancaVelha. Jogador: "+atual);

	}

	public boolean compCell(int c11,int c12,int c21, int c22)
	{
		/*
		 *Compara duas células.
		 */
		if( (celulas[c11][c12].getIcon()!=null) && (celulas[c21][c22].getIcon()!=null) )
		{

			if(celulas[c11][c12].getIcon().equals(celulas[c21][c22].getIcon()))
			{
				return true;
			}
		}
		return false;
	}
	public String calcLinha()
	{
		/*
		 *Calcula a força bruta se alguma linha foi preenchida.
		 */
		if( (compCell(0,0,0,1)) && (compCell(0,1,0,2)) )
		{
			if(celulas[0][0].getIcon().equals(xis))
				return "x";
			else
				return "0";
		}
		if(	(compCell(1,0,1,1)) && (compCell(1,1,1,2)) )
		{
			if(celulas[1][0].getIcon().equals(xis))
				return "x";
			else
				return "0";
		}
		if	( (compCell(2,0,2,1)) && (compCell(2,1,2,2)) )
		{
			if(celulas[2][0].getIcon().equals(xis))
				return "x";
			else
				return "0";
		}
		return null;
	}

	public String calcColuna()
	{
		/*
		 *Calcula a força bruta se alguma coluna foi preenchida.
		 */
		if( (compCell(0,0,1,0)) && (compCell(1,0,2,0)) )
		{
			if(celulas[0][0].getIcon().equals(xis))
				return "x";
			else
				return "0";
		}
		if(	(compCell(0,1,1,1)) && (compCell(1,1,2,1)) )
		{
			if(celulas[0][1].getIcon().equals(xis))
				return "x";
			else
				return "0";
		}
		if	( (compCell(0,2,1,2)) && (compCell(1,2,2,2)) )
		{
			if(celulas[0][2].getIcon().equals(xis))
				return "x";
			else
				return "0";
		}
		return null;
	}

	public String calcDiagonais()
	{
		/*
		 *Calcula a força bruta se as diagonais completam um jogo.
		 */
		if( (compCell(0,0,1,1)) && (compCell(1,1,2,2)) )
		{
			if(celulas[0][0].getIcon().equals(xis))
				return "x";
			else
				return "0";
		}
		if( (compCell(0,2,1,1)) && (compCell(1,1,2,0)) )
		{
			if(celulas[0][2].getIcon().equals(xis))
				return "x";
			else
				return "0";
		}
		return null;
	}

	public boolean empate()
	{
		/*
		 *Este método será chamado se não houver ganhador (verificado nos métodos anteriores).
		 *Verifica todas células, vendo se existe alguma vazia.
		 */
		boolean tmp=true;
		for(int i =0;i< 3; i++)
		{
			for(int j=0;j<3;j++)
			{
				if(celulas[i][j].getIcon()==null)
					tmp=false;//se tiver alguma que nao foi marcada, ainda nao ocorreu empate.
			}
		}
		return tmp;
	}

	public boolean acabou()
	{
		return fimDeJogo;//verifica se o jogo acabou. Nao utilizado...
	}


	public void newGame()
	{
		/*
		 *Exibe um painel de opção. Cada botao tem um numero, começando do 0. Como o "YES" é o primeiro (esquerda para direita)
		 *seu número é 0. Este número é retornado assim que o botão é pressionado, então se o retorno for 0, um novo jogo começa.
		 */
		if(JOptionPane.showConfirmDialog(null, "Novo jogo?", "Novo", JOptionPane.YES_NO_OPTION, JOptionPane.YES_NO_OPTION, null)==0)
		{
				posX=janela.getX();//guarda a posição da janela, para que outra seja criada na mesma.
				posY=janela.getY();
				janela.setVisible(false);
				setScreen();
		}
		else
			System.exit(0);
	}

	public static void main(String[] args)
	{

		Tabuleiro t = new Tabuleiro();
	}

}

Copiei e colei o codigo e continuo nao vendo as imgs !
Como vc importa as imgs para o netbeans ?

Obnrigado

Cara que estranho!

Aparentemente esta certo (as imagens onde estão).Alem disso esse codigo eu usei aqui e funcionou perfeitamente (com imagens inclusive).
Mas sei la …Renomeia as imagens para a extensão em minusculo muda o formato (manda benzer :smiley: )…

A saquei …seguinte eu não tava usando o NetBeans, ja que dentro dele voce tem que definir o caminho da seguinte maneira :

xis = new ImageIcon("src//jogodavelha//xis.jpg"); //atenção aqui já que o Java difere de maiusculo e minusculo 

Isso já resolve :smiley:

criei um projeto novo e deixei assim:

Muito Obrigado Markus !

Beleza :slight_smile:

fiz umas alterações e envio funcionando com imagens embutidas etc e tal… posso enviar tudo separado também

aqui segue o programa em separado se alguém quiser estudar as mudanças, etc e tal… com imagens para acoplar junto ao programa java.



package jogo_da_velha;

import java.awt.Color;
import javax.swing.JFrame;
import javax.swing.JOptionPane;

/**
*

  • @author Dhiego Verona
    */
    public class jogo_da_velha extends javax.swing.JFrame {

//*@author Dhiego Verona
int quemjoga = 0;

//funcao que ira preencher os botões
public String acao(int botao) {
    String XO = "";
    if (quemjoga == 0) {
        XO = "X";
        quemjoga = 1;
        jLabel2.setText("Vez do Jogador2");
        //quando for jogador 
    } else {
        XO = "0";
        quemjoga = 0;
        jLabel2.setText("Vez do Jogador1");
    }
   
    //retorna o valor
    return XO;
}
    //Funcao para ver quem ganhou
    public void  verifica(String XO){
        if ((jButton2.getText().equals(XO))&&
            (jButton3.getText().equals(XO))&&
            (jButton4.getText().equals(XO))){    
            
            
            JOptionPane.showMessageDialog(null,"Ganhou!"+XO);
        }
        
        if ((jButton2.getText().equals(XO))&&
            (jButton5.getText().equals(XO))&&
            (jButton8.getText().equals(XO))){    
            JOptionPane.showMessageDialog(null,"Ganhou!"+XO);
    }
         
        if ((jButton3.getText().equals(XO))&&
            (jButton6.getText().equals(XO))&&
            (jButton9.getText().equals(XO))){    
            JOptionPane.showMessageDialog(null,"Ganhou!"+XO);
}
         if ((jButton2.getText().equals(XO))&&
            (jButton6.getText().equals(XO))&&
            (jButton10.getText().equals(XO))){    
            JOptionPane.showMessageDialog(null,"Ganhou!"+XO);
}
          if ((jButton4.getText().equals(XO))&&
            (jButton7.getText().equals(XO))&&
            (jButton10.getText().equals(XO))){    
            JOptionPane.showMessageDialog(null,"Ganhou!"+XO);
}
           if ((jButton8.getText().equals(XO))&&
            (jButton9.getText().equals(XO))&&
            (jButton10.getText().equals(XO))){    
            JOptionPane.showMessageDialog(null,"Ganhou!"+XO);
}
            if ((jButton5.getText().equals(XO))&&
            (jButton6.getText().equals(XO))&&
            (jButton7.getText().equals(XO))){    
            JOptionPane.showMessageDialog(null,"Ganhou!"+XO);
}
             if ((jButton4.getText().equals(XO))&&
            (jButton6.getText().equals(XO))&&
            (jButton8.getText().equals(XO))){    
            JOptionPane.showMessageDialog(null,"Ganhou!"+XO);
}

}
/**
* Creates new form jogo_da_velha
*/
public jogo_da_velha() {
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="collapsed" desc="Generated Code">                          
private void initComponents() {

    jPanel1 = new javax.swing.JPanel();
    jLabel1 = new javax.swing.JLabel();
    jButton1 = new javax.swing.JButton();
    jButton2 = new javax.swing.JButton();
    jButton3 = new javax.swing.JButton();
    jButton4 = new javax.swing.JButton();
    jButton5 = new javax.swing.JButton();
    jButton6 = new javax.swing.JButton();
    jButton7 = new javax.swing.JButton();
    jButton8 = new javax.swing.JButton();
    jButton9 = new javax.swing.JButton();
    jButton10 = new javax.swing.JButton();
    jLabel2 = new javax.swing.JLabel();

    setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
    setTitle("                                           ..:Joguinho da Veia:..");

    jPanel1.setBorder(javax.swing.BorderFactory.createCompoundBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0), 5), javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0), 3)));
    jPanel1.setFont(new java.awt.Font("Tahoma", 0, 36)); // NOI18N

    jLabel1.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
    jLabel1.setForeground(new java.awt.Color(51, 51, 255));
    jLabel1.setText("..:Jogo da Velha:..");

    jButton1.setForeground(new java.awt.Color(255, 0, 0));
    jButton1.setText("Novo");
    jButton1.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jButton1ActionPerformed(evt);
        }
    });

    jButton2.setForeground(new java.awt.Color(255, 0, 0));
    jButton2.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jButton2ActionPerformed(evt);
        }
    });

    jButton3.setForeground(new java.awt.Color(255, 0, 0));
    jButton3.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jButton3ActionPerformed(evt);
        }
    });

    jButton4.setForeground(new java.awt.Color(255, 0, 0));
    jButton4.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jButton4ActionPerformed(evt);
        }
    });

    jButton5.setForeground(new java.awt.Color(255, 0, 0));
    jButton5.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jButton5ActionPerformed(evt);
        }
    });

    jButton6.setForeground(new java.awt.Color(255, 0, 0));
    jButton6.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jButton6ActionPerformed(evt);
        }
    });

    jButton7.setForeground(new java.awt.Color(255, 0, 0));
    jButton7.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jButton7ActionPerformed(evt);
        }
    });

    jButton8.setForeground(new java.awt.Color(255, 0, 0));
    jButton8.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jButton8ActionPerformed(evt);
        }
    });

    jButton9.setForeground(new java.awt.Color(255, 0, 0));
    jButton9.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jButton9ActionPerformed(evt);
        }
    });

    jButton10.setForeground(new java.awt.Color(255, 0, 0));
    jButton10.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jButton10ActionPerformed(evt);
        }
    });

    jLabel2.setText("     Vez do Jogador1");

    javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
    jPanel1.setLayout(jPanel1Layout);
    jPanel1Layout.setHorizontalGroup(
        jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGroup(jPanel1Layout.createSequentialGroup()
            .addContainerGap()
            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel1Layout.createSequentialGroup()
                    .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 76, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 113, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGroup(jPanel1Layout.createSequentialGroup()
                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 84, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jButton5, javax.swing.GroupLayout.PREFERRED_SIZE, 84, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jButton8, javax.swing.GroupLayout.PREFERRED_SIZE, 84, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addComponent(jButton6, javax.swing.GroupLayout.PREFERRED_SIZE, 84, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jButton9, javax.swing.GroupLayout.PREFERRED_SIZE, 84, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jButton3, javax.swing.GroupLayout.PREFERRED_SIZE, 84, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addComponent(jButton7, javax.swing.GroupLayout.PREFERRED_SIZE, 84, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jButton4, javax.swing.GroupLayout.PREFERRED_SIZE, 84, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jButton10, javax.swing.GroupLayout.PREFERRED_SIZE, 86, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGroup(jPanel1Layout.createSequentialGroup()
                    .addGap(42, 42, 42)
                    .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 177, javax.swing.GroupLayout.PREFERRED_SIZE)))
            .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
    );
    jPanel1Layout.setVerticalGroup(
        jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGroup(jPanel1Layout.createSequentialGroup()
            .addContainerGap()
            .addComponent(jLabel1)
            .addGap(18, 18, 18)
            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                .addComponent(jButton1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
            .addGap(28, 28, 28)
            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addComponent(jButton3, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 73, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addComponent(jButton4, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 73, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 73, javax.swing.GroupLayout.PREFERRED_SIZE))
            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addComponent(jButton5, javax.swing.GroupLayout.PREFERRED_SIZE, 69, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addComponent(jButton6, javax.swing.GroupLayout.PREFERRED_SIZE, 69, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addComponent(jButton7, javax.swing.GroupLayout.PREFERRED_SIZE, 69, javax.swing.GroupLayout.PREFERRED_SIZE))
            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                .addComponent(jButton8, javax.swing.GroupLayout.DEFAULT_SIZE, 70, Short.MAX_VALUE)
                .addComponent(jButton9, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jButton10, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
            .addContainerGap())
    );

    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
    getContentPane().setLayout(layout);
    layout.setHorizontalGroup(
        layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
    );
    layout.setVerticalGroup(
        layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addComponent(jPanel1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
    );

    pack();
    setLocationRelativeTo(null);
}// </editor-fold>                        

private void jButton9ActionPerformed(java.awt.event.ActionEvent evt) {                                         
    // TODO add your handling code here:
    jButton9.setText(acao(8));
    jButton9.setEnabled(false);
    verifica(jButton9.getText());
}                                        

private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {                                         
    // TODO add your handling code here:
    jButton2.setText(acao(1));
    jButton2.setEnabled(false);
    verifica(jButton2.getText());
}                                        

private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {                                         
    // TODO add your handling code here:
    jButton3.setText(acao(2));
    jButton3.setEnabled(false);
    verifica(jButton3.getText());
}                                        

private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {                                         
    // TODO add your handling code here:
    jButton4.setText(acao(3));
    jButton4.setEnabled(false);
    verifica(jButton4.getText());
}                                        

private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {                                         
    // TODO add your handling code here:
    jButton5.setText(acao(4));
    jButton5.setEnabled(false);
    verifica(jButton5.getText());
}                                        

private void jButton6ActionPerformed(java.awt.event.ActionEvent evt) {                                         
    // TODO add your handling code here:
    jButton6.setText(acao(5));
    jButton6.setEnabled(false);
    verifica(jButton6.getText());
}                                        

private void jButton7ActionPerformed(java.awt.event.ActionEvent evt) {                                         
    // TODO add your handling code here:
    jButton7.setText(acao(6));
    jButton7.setEnabled(false);
    verifica(jButton7.getText());
}                                        

private void jButton8ActionPerformed(java.awt.event.ActionEvent evt) {                                         
    // TODO add your handling code here:
    jButton8.setText(acao(7));
    jButton8.setEnabled(false);
    verifica(jButton8.getText());
}                                        

private void jButton10ActionPerformed(java.awt.event.ActionEvent evt) {                                          
    // TODO add your handling code here:
    jButton10.setText(acao(9));
    jButton10.setEnabled(false);
    verifica(jButton10.getText());
}                                         

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                         
    // TODO add your handling code here:
    jLabel2.setText("Vez do Jogador1");
    jButton2.setText("");
    jButton3.setText("");
    jButton4.setText("");
    jButton5.setText("");
    jButton6.setText("");
    jButton7.setText("");
    jButton8.setText("");
    jButton9.setText("");
    jButton10.setText("");
    jButton2.setEnabled(true);
    jButton3.setEnabled(true);
    jButton4.setEnabled(true);
    jButton5.setEnabled(true);
    jButton6.setEnabled(true);
    jButton7.setEnabled(true);
    jButton8.setEnabled(true);
    jButton9.setEnabled(true);
    jButton10.setEnabled(true);
    
    
}                                        

/**
 * @param args the command line arguments
 */
public static void main(String args[]) {
    /* Set the Nimbus look and feel */
    //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
    /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
     * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
     */
    try {
        for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
            if ("Nimbus".equals(info.getName())) {
                javax.swing.UIManager.setLookAndFeel(info.getClassName());
                break;
            }
        }
    } catch (ClassNotFoundException ex) {
        java.util.logging.Logger.getLogger(jogo_da_velha.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
    } catch (InstantiationException ex) {
        java.util.logging.Logger.getLogger(jogo_da_velha.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
    } catch (IllegalAccessException ex) {
        java.util.logging.Logger.getLogger(jogo_da_velha.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
    } catch (javax.swing.UnsupportedLookAndFeelException ex) {
        java.util.logging.Logger.getLogger(jogo_da_velha.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
    }
    //</editor-fold>

    /* Create and display the form */
    java.awt.EventQueue.invokeLater(new Runnable() {
        public void run() {
            new jogo_da_velha().setVisible(true);
        }
    });
}

// Variables declaration - do not modify                     
private javax.swing.JButton jButton1;
private javax.swing.JButton jButton10;
private javax.swing.JButton jButton2;
private javax.swing.JButton jButton3;
private javax.swing.JButton jButton4;
private javax.swing.JButton jButton5;
private javax.swing.JButton jButton6;
private javax.swing.JButton jButton7;
private javax.swing.JButton jButton8;
private javax.swing.JButton jButton9;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JPanel jPanel1;
// End of variables declaration                   

}

package jogo_da_velha;

import java.awt.Color;
import javax.swing.JFrame;
import javax.swing.JOptionPane;

/**
*

  • @author Dhiego Verona
    */
    public class jogo_da_velha extends javax.swing.JFrame {

//*@author Dhiego Verona
int quemjoga = 0;

//funcao que ira preencher os botões
public String acao(int botao) {
    String XO = "";
    if (quemjoga == 0) {
        XO = "X";
        quemjoga = 1;
        jLabel2.setText("Vez do Jogador2");
        //quando for jogador 
    } else {
        XO = "0";
        quemjoga = 0;
        jLabel2.setText("Vez do Jogador1");
    }
   
    //retorna o valor
    return XO;
}
    //Funcao para ver quem ganhou
    public void  verifica(String XO){
        if ((jButton2.getText().equals(XO))&&
            (jButton3.getText().equals(XO))&&
            (jButton4.getText().equals(XO))){    
            
            
            JOptionPane.showMessageDialog(null,"Ganhou!"+XO);
        }
        
        if ((jButton2.getText().equals(XO))&&
            (jButton5.getText().equals(XO))&&
            (jButton8.getText().equals(XO))){    
            JOptionPane.showMessageDialog(null,"Ganhou!"+XO);
    }
         
        if ((jButton3.getText().equals(XO))&&
            (jButton6.getText().equals(XO))&&
            (jButton9.getText().equals(XO))){    
            JOptionPane.showMessageDialog(null,"Ganhou!"+XO);
}
         if ((jButton2.getText().equals(XO))&&
            (jButton6.getText().equals(XO))&&
            (jButton10.getText().equals(XO))){    
            JOptionPane.showMessageDialog(null,"Ganhou!"+XO);
}
          if ((jButton4.getText().equals(XO))&&
            (jButton7.getText().equals(XO))&&
            (jButton10.getText().equals(XO))){    
            JOptionPane.showMessageDialog(null,"Ganhou!"+XO);
}
           if ((jButton8.getText().equals(XO))&&
            (jButton9.getText().equals(XO))&&
            (jButton10.getText().equals(XO))){    
            JOptionPane.showMessageDialog(null,"Ganhou!"+XO);
}
            if ((jButton5.getText().equals(XO))&&
            (jButton6.getText().equals(XO))&&
            (jButton7.getText().equals(XO))){    
            JOptionPane.showMessageDialog(null,"Ganhou!"+XO);
}
             if ((jButton4.getText().equals(XO))&&
            (jButton6.getText().equals(XO))&&
            (jButton8.getText().equals(XO))){    
            JOptionPane.showMessageDialog(null,"Ganhou!"+XO);
}

}
/**
* Creates new form jogo_da_velha
*/
public jogo_da_velha() {
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="collapsed" desc="Generated Code">                          
private void initComponents() {

    jPanel1 = new javax.swing.JPanel();
    jLabel1 = new javax.swing.JLabel();
    jButton1 = new javax.swing.JButton();
    jButton2 = new javax.swing.JButton();
    jButton3 = new javax.swing.JButton();
    jButton4 = new javax.swing.JButton();
    jButton5 = new javax.swing.JButton();
    jButton6 = new javax.swing.JButton();
    jButton7 = new javax.swing.JButton();
    jButton8 = new javax.swing.JButton();
    jButton9 = new javax.swing.JButton();
    jButton10 = new javax.swing.JButton();
    jLabel2 = new javax.swing.JLabel();

    setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
    setTitle("                                           ..:Joguinho da Veia:..");

    jPanel1.setBorder(javax.swing.BorderFactory.createCompoundBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0), 5), javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0), 3)));
    jPanel1.setFont(new java.awt.Font("Tahoma", 0, 36)); // NOI18N

    jLabel1.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
    jLabel1.setForeground(new java.awt.Color(51, 51, 255));
    jLabel1.setText("..:Jogo da Velha:..");

    jButton1.setForeground(new java.awt.Color(255, 0, 0));
    jButton1.setText("Novo");
    jButton1.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jButton1ActionPerformed(evt);
        }
    });

    jButton2.setForeground(new java.awt.Color(255, 0, 0));
    jButton2.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jButton2ActionPerformed(evt);
        }
    });

    jButton3.setForeground(new java.awt.Color(255, 0, 0));
    jButton3.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jButton3ActionPerformed(evt);
        }
    });

    jButton4.setForeground(new java.awt.Color(255, 0, 0));
    jButton4.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jButton4ActionPerformed(evt);
        }
    });

    jButton5.setForeground(new java.awt.Color(255, 0, 0));
    jButton5.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jButton5ActionPerformed(evt);
        }
    });

    jButton6.setForeground(new java.awt.Color(255, 0, 0));
    jButton6.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jButton6ActionPerformed(evt);
        }
    });

    jButton7.setForeground(new java.awt.Color(255, 0, 0));
    jButton7.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jButton7ActionPerformed(evt);
        }
    });

    jButton8.setForeground(new java.awt.Color(255, 0, 0));
    jButton8.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jButton8ActionPerformed(evt);
        }
    });

    jButton9.setForeground(new java.awt.Color(255, 0, 0));
    jButton9.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jButton9ActionPerformed(evt);
        }
    });

    jButton10.setForeground(new java.awt.Color(255, 0, 0));
    jButton10.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jButton10ActionPerformed(evt);
        }
    });

    jLabel2.setText("     Vez do Jogador1");

    javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
    jPanel1.setLayout(jPanel1Layout);
    jPanel1Layout.setHorizontalGroup(
        jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGroup(jPanel1Layout.createSequentialGroup()
            .addContainerGap()
            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel1Layout.createSequentialGroup()
                    .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 76, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 113, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGroup(jPanel1Layout.createSequentialGroup()
                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 84, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jButton5, javax.swing.GroupLayout.PREFERRED_SIZE, 84, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jButton8, javax.swing.GroupLayout.PREFERRED_SIZE, 84, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addComponent(jButton6, javax.swing.GroupLayout.PREFERRED_SIZE, 84, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jButton9, javax.swing.GroupLayout.PREFERRED_SIZE, 84, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jButton3, javax.swing.GroupLayout.PREFERRED_SIZE, 84, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addComponent(jButton7, javax.swing.GroupLayout.PREFERRED_SIZE, 84, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jButton4, javax.swing.GroupLayout.PREFERRED_SIZE, 84, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jButton10, javax.swing.GroupLayout.PREFERRED_SIZE, 86, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGroup(jPanel1Layout.createSequentialGroup()
                    .addGap(42, 42, 42)
                    .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 177, javax.swing.GroupLayout.PREFERRED_SIZE)))
            .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
    );
    jPanel1Layout.setVerticalGroup(
        jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGroup(jPanel1Layout.createSequentialGroup()
            .addContainerGap()
            .addComponent(jLabel1)
            .addGap(18, 18, 18)
            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                .addComponent(jButton1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
            .addGap(28, 28, 28)
            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addComponent(jButton3, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 73, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addComponent(jButton4, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 73, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 73, javax.swing.GroupLayout.PREFERRED_SIZE))
            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addComponent(jButton5, javax.swing.GroupLayout.PREFERRED_SIZE, 69, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addComponent(jButton6, javax.swing.GroupLayout.PREFERRED_SIZE, 69, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addComponent(jButton7, javax.swing.GroupLayout.PREFERRED_SIZE, 69, javax.swing.GroupLayout.PREFERRED_SIZE))
            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                .addComponent(jButton8, javax.swing.GroupLayout.DEFAULT_SIZE, 70, Short.MAX_VALUE)
                .addComponent(jButton9, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jButton10, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
            .addContainerGap())
    );

    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
    getContentPane().setLayout(layout);
    layout.setHorizontalGroup(
        layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
    );
    layout.setVerticalGroup(
        layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addComponent(jPanel1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
    );

    pack();
    setLocationRelativeTo(null);
}// </editor-fold>                        

private void jButton9ActionPerformed(java.awt.event.ActionEvent evt) {                                         
    // TODO add your handling code here:
    jButton9.setText(acao(8));
    jButton9.setEnabled(false);
    verifica(jButton9.getText());
}                                        

private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {                                         
    // TODO add your handling code here:
    jButton2.setText(acao(1));
    jButton2.setEnabled(false);
    verifica(jButton2.getText());
}                                        

private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {                                         
    // TODO add your handling code here:
    jButton3.setText(acao(2));
    jButton3.setEnabled(false);
    verifica(jButton3.getText());
}                                        

private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {                                         
    // TODO add your handling code here:
    jButton4.setText(acao(3));
    jButton4.setEnabled(false);
    verifica(jButton4.getText());
}                                        

private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {                                         
    // TODO add your handling code here:
    jButton5.setText(acao(4));
    jButton5.setEnabled(false);
    verifica(jButton5.getText());
}                                        

private void jButton6ActionPerformed(java.awt.event.ActionEvent evt) {                                         
    // TODO add your handling code here:
    jButton6.setText(acao(5));
    jButton6.setEnabled(false);
    verifica(jButton6.getText());
}                                        

private void jButton7ActionPerformed(java.awt.event.ActionEvent evt) {                                         
    // TODO add your handling code here:
    jButton7.setText(acao(6));
    jButton7.setEnabled(false);
    verifica(jButton7.getText());
}                                        

private void jButton8ActionPerformed(java.awt.event.ActionEvent evt) {                                         
    // TODO add your handling code here:
    jButton8.setText(acao(7));
    jButton8.setEnabled(false);
    verifica(jButton8.getText());
}                                        

private void jButton10ActionPerformed(java.awt.event.ActionEvent evt) {                                          
    // TODO add your handling code here:
    jButton10.setText(acao(9));
    jButton10.setEnabled(false);
    verifica(jButton10.getText());
}                                         

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                         
    // TODO add your handling code here:
    jLabel2.setText("Vez do Jogador1");
    jButton2.setText("");
    jButton3.setText("");
    jButton4.setText("");
    jButton5.setText("");
    jButton6.setText("");
    jButton7.setText("");
    jButton8.setText("");
    jButton9.setText("");
    jButton10.setText("");
    jButton2.setEnabled(true);
    jButton3.setEnabled(true);
    jButton4.setEnabled(true);
    jButton5.setEnabled(true);
    jButton6.setEnabled(true);
    jButton7.setEnabled(true);
    jButton8.setEnabled(true);
    jButton9.setEnabled(true);
    jButton10.setEnabled(true);
    
    
}                                        

/**
 * @param args the command line arguments
 */
public static void main(String args[]) {
    /* Set the Nimbus look and feel */
    //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
    /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
     * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
     */
    try {
        for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
            if ("Nimbus".equals(info.getName())) {
                javax.swing.UIManager.setLookAndFeel(info.getClassName());
                break;
            }
        }
    } catch (ClassNotFoundException ex) {
        java.util.logging.Logger.getLogger(jogo_da_velha.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
    } catch (InstantiationException ex) {
        java.util.logging.Logger.getLogger(jogo_da_velha.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
    } catch (IllegalAccessException ex) {
        java.util.logging.Logger.getLogger(jogo_da_velha.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
    } catch (javax.swing.UnsupportedLookAndFeelException ex) {
        java.util.logging.Logger.getLogger(jogo_da_velha.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
    }
    //</editor-fold>

    /* Create and display the form */
    java.awt.EventQueue.invokeLater(new Runnable() {
        public void run() {
            new jogo_da_velha().setVisible(true);
        }
    });
}

// Variables declaration - do not modify                     
private javax.swing.JButton jButton1;
private javax.swing.JButton jButton10;
private javax.swing.JButton jButton2;
private javax.swing.JButton jButton3;
private javax.swing.JButton jButton4;
private javax.swing.JButton jButton5;
private javax.swing.JButton jButton6;
private javax.swing.JButton jButton7;
private javax.swing.JButton jButton8;
private javax.swing.JButton jButton9;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JPanel jPanel1;
// End of variables declaration                   

}