Boa Noite amigos, estou precisando de ajuda com o seguinte problema do meu TCC, que são varios jogos feitos em J2SE, e esse é o Palavras Cruzadas. pois bem…
preciso verificar no meu frmFimDoJogo se a variavel int level é igual à 1, que está no frmPalavrasCruzadasLV1facil. Porem como faço pra ler essa variavel dentro de outra classe, que está em outro arquivo .java ? ja deixei como
public int level = 0;
mas nada, ele pede pra colocar um try - catch doido la. :shock:
se puderem me ajudar agradeço, vou postar abaixo meu código das duas classes
frmPalavrasCruzadasLV1facil:
[code]import java.awt.;
import javax.swing.JFormattedTextField;
import javax.swing.JFrame;
import javax.swing.JTextField;
import javax.swing.text.JTextComponent;
import javax.swing.text.MaskFormatter;
import java.awt.event.;
import java.text.ParseException;
import javax.swing.;
import javax.swing.event.;
public class frmPalavrasCruzadasLV1facil extends JFrame {
private JButton btnNovoJogo, btnAjuda, btnSair, btnEstatisticas, btnVerificar;
private JLabel lblAnimal1, lblAnimal2, lblAnimal3, lblAnimal4, lblAnimal5, lblImagem, lblJogo, lblTitulo, lblImgAnimal1, lblImgAnimal2, lblImgAnimal3, lblImgAnimal4, lblImgAnimal5;
private JFormattedTextField txt1, txt2, txt3, txt4, txt5, txt6, txt7, txt8, txt9, txt10, txt11, txt12, txt13, txt14, txt15, /txt16,/ txt17, txt18/, txt19, txt20/;
private MaskFormatter ftmtxt1, ftmtxt2, ftmtxt3, ftmtxt4, ftmtxt5, ftmtxt6, ftmtxt7, ftmtxt8, ftmtxt9, ftmtxt10, ftmtxt11, ftmtxt12, ftmtxt13, ftmtxt14, ftmtxt15, /ftmtxt16,/ ftmtxt17, ftmtxt18/,ftmtxt19, ftmtxt20/;
public int pontuacao =0;
public int level1 = 0;
Font fonte = new Font("A.C.M.E. Secret Agent",Font.CENTER_BASELINE,20);
public frmPalavrasCruzadasLV1facil() throws ParseException {
this.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);
this.setUndecorated(true);
this.setSize(1024,700);
this.setResizable(false);
//this.setVisible (true);
this.setLocationRelativeTo(null);//Centralizar o formulário
//construtor
lblAnimal1 = new JLabel ("Elefante");
lblAnimal2 = new JLabel ("Gato");
lblAnimal3 = new JLabel ("Cisne");
lblAnimal4 = new JLabel ("Boi");
//lblCor5 = new JLabel ("Branco");
lblTitulo = new JLabel ("Cruzadinha dos Animais");
btnNovoJogo = new JButton("Novo Jogo");
btnAjuda = new JButton("Ajuda");
btnEstatisticas = new JButton("Estatísticas");
btnSair = new JButton("Sair");
btnVerificar = new JButton("Verificar");
txt1 = new JFormattedTextField();
txt2 = new JFormattedTextField();
txt3 = new JFormattedTextField();
txt4 = new JFormattedTextField();
txt5 = new JFormattedTextField();
txt6 = new JFormattedTextField();
txt7 = new JFormattedTextField();
txt8 = new JFormattedTextField();
txt9 = new JFormattedTextField();
txt10 = new JFormattedTextField();
txt11 = new JFormattedTextField();
txt12 = new JFormattedTextField();
txt13 = new JFormattedTextField();
txt14 = new JFormattedTextField();
txt15 = new JFormattedTextField();
// txt16 = new JFormattedTextField();
txt17 = new JFormattedTextField();
txt18 = new JFormattedTextField();
//txt19 = new JFormattedTextField();
//txt20 = new JFormattedTextField();
ftmtxt1 = new MaskFormatter();
ftmtxt1.setMask("*");
ftmtxt1.setInvalidCharacters("0123456789 ");
ftmtxt1.install(txt1);
txt1.setColumns(1);
ftmtxt2 = new MaskFormatter();
ftmtxt2.setMask("*");
ftmtxt2.setInvalidCharacters("0123456789 ");
ftmtxt2.install(txt2);
txt2.setColumns(1);
ftmtxt3 = new MaskFormatter();
ftmtxt3.setMask("*");
ftmtxt3.setInvalidCharacters("0123456789 ");
ftmtxt3.install(txt3);
txt3.setColumns(1);
ftmtxt4 = new MaskFormatter();
ftmtxt4.setMask("*");
ftmtxt4.setInvalidCharacters("0123456789 ");
ftmtxt4.install(txt4);
txt4.setColumns(1);
ftmtxt5 = new MaskFormatter();
ftmtxt5.setMask("*");
ftmtxt5.setInvalidCharacters("0123456789 ");
ftmtxt5.install(txt5);
txt5.setColumns(1);
ftmtxt6 = new MaskFormatter();
ftmtxt6.setMask("*");
ftmtxt6.setInvalidCharacters("0123456789 ");
ftmtxt6.install(txt6);
txt6.setColumns(1);
ftmtxt7 = new MaskFormatter();
ftmtxt7.setMask("*");
ftmtxt7.setInvalidCharacters("0123456789 ");
ftmtxt7.install(txt7);
txt7.setColumns(1);
ftmtxt8 = new MaskFormatter();
ftmtxt8.setMask("*");
ftmtxt8.setInvalidCharacters("0123456789 ");
ftmtxt8.install(txt8);
txt8.setColumns(1);
ftmtxt9 = new MaskFormatter();
ftmtxt9.setMask("*");
ftmtxt9.setInvalidCharacters("0123456789 ");
ftmtxt9.install(txt9);
txt9.setColumns(1);
ftmtxt10 = new MaskFormatter();
ftmtxt10.setMask("*");
ftmtxt10.setInvalidCharacters("0123456789 ");
ftmtxt10.install(txt10);
txt10.setColumns(1);
ftmtxt11 = new MaskFormatter();
ftmtxt11.setMask("*");
ftmtxt11.setInvalidCharacters("0123456789 ");
ftmtxt11.install(txt11);
txt11.setColumns(1);
ftmtxt12 = new MaskFormatter();
ftmtxt12.setMask("*");
ftmtxt12.setInvalidCharacters("0123456789 ");
ftmtxt12.install(txt12);
txt12.setColumns(1);
ftmtxt13 = new MaskFormatter();
ftmtxt13.setMask("*");
ftmtxt13.setInvalidCharacters("0123456789 ");
ftmtxt13.install(txt13);
txt13.setColumns(1);
ftmtxt14 = new MaskFormatter();
ftmtxt14.setMask("*");
ftmtxt14.setInvalidCharacters("0123456789 ");
ftmtxt14.install(txt14);
txt14.setColumns(1);
ftmtxt15 = new MaskFormatter();
ftmtxt15.setMask("*");
ftmtxt15.setInvalidCharacters("0123456789 ");
ftmtxt15.install(txt15);
txt15.setColumns(1);
/* ftmtxt16 = new MaskFormatter();
ftmtxt16.setMask("*");
ftmtxt16.setInvalidCharacters("0123456789 ");
ftmtxt16.install(txt16);
txt16.setColumns(1);*/
ftmtxt17 = new MaskFormatter();
ftmtxt17.setMask("*");
ftmtxt17.setInvalidCharacters("0123456789 ");
ftmtxt17.install(txt17);
txt17.setColumns(1);
ftmtxt18 = new MaskFormatter();
ftmtxt18.setMask("*");
ftmtxt18.setInvalidCharacters("0123456789 ");
ftmtxt18.install(txt18);
txt18.setColumns(1);
/* ftmtxt19 = new MaskFormatter();
ftmtxt19.setMask("*");
ftmtxt19.setInvalidCharacters("0123456789 ");
ftmtxt19.install(txt19);
txt19.setColumns(1);
ftmtxt20 = new MaskFormatter();
ftmtxt20.setMask("*");
ftmtxt20.setInvalidCharacters("0123456789 ");
ftmtxt20.install(txt20);
txt20.setColumns(1);*/
//adjust size and set layout
setPreferredSize (new Dimension (1024, 700));
setLayout (null);
//add components
add (btnSair);
add (btnAjuda);
add (btnNovoJogo);
add (btnEstatisticas);
add (btnVerificar);
add (lblAnimal1);
add (lblAnimal2);
add (lblAnimal3);
add (lblAnimal4);
add (lblTitulo);
add (txt1);
add (txt2);
add (txt3);
add (txt4);
add (txt5);
add (txt6);
add (txt7);
add (txt8);
add (txt9);
add (txt10);
add (txt11);
add (txt12);
add (txt13);
add (txt14);
add (txt15);
// add (txt16);
add (txt17);
add (txt18);
// add (txt19);
// add (txt20);
//set component bounds (only needed by Absolute Positioning)
btnSair.setBounds (820, 650, 100, 35);
btnEstatisticas.setBounds(600,650,110,35);
btnAjuda.setBounds (350, 650, 100, 35);
btnNovoJogo.setBounds (100, 650, 100, 35);
btnVerificar = new JButton();
btnVerificar.setBounds (550,330, 100,100);
btnVerificar.setIcon(new ImageIcon("imagens/validar.jpg"));
btnVerificar.setBorder(null);
add (btnVerificar);
lblAnimal1.setBounds (750, 380, 200, 25);
lblAnimal1.setFont(new Font("A.C.M.E. Secret Agent",Font.CENTER_BASELINE,18));
// lblCor1.setForeground(Color.YELLOW);
lblAnimal2.setBounds (750, 420, 200, 25);
lblAnimal2.setFont(new Font("A.C.M.E. Secret Agent",Font.CENTER_BASELINE,18));
//lblCor2.setForeground(Color.BLUE);
lblAnimal3.setBounds (750, 460, 200, 25);
lblAnimal3.setFont(new Font("A.C.M.E. Secret Agent",Font.CENTER_BASELINE,18));
//lblCor3.setForeground(Color.GREEN);
lblAnimal4.setBounds (750, 500, 200, 25);
lblAnimal4.setFont(fonte);
//lblCor4.setForeground(Color.RED);
//lblAnimal5.setBounds (750, 540, 200, 25);
// lblAnimal5.setFont(new Font("A.C.M.E. Secret Agent",Font.CENTER_BASELINE,18));
// lblAnimal5.setForeground(Color.WHITE);
lblTitulo.setBounds(600,60,300,25);
lblTitulo.setFont(new Font("A.C.M.E. Secret Agent",Font.CENTER_BASELINE,18));
//Posição dos JTextField's
txt1.setBounds(28,50,41,40);
txt1.setFont(new Font("A.C.M.E. Secret Agent",Font.CENTER_BASELINE,20));
txt2.setBounds(85,50,41,40);
txt2.setFont(new Font("A.C.M.E. Secret Agent",Font.CENTER_BASELINE,20));
txt3.setBounds(140,50,41,40);
txt3.setFont(new Font("A.C.M.E. Secret Agent",Font.CENTER_BASELINE,20));
txt4.setBounds(195,50,41,40);
txt4.setFont(new Font("A.C.M.E. Secret Agent",Font.CENTER_BASELINE,20));
txt5.setBounds(245,50,41,40);
txt5.setFont(new Font("A.C.M.E. Secret Agent",Font.CENTER_BASELINE,20));
txt6.setBounds(245,105,41,40);
txt6.setFont(new Font("A.C.M.E. Secret Agent",Font.CENTER_BASELINE,20));
txt7.setBounds(245,162,41,40);
txt7.setFont(new Font("A.C.M.E. Secret Agent",Font.CENTER_BASELINE,20));
txt8.setBounds(247,217,41,40);
txt8.setFont(new Font("A.C.M.E. Secret Agent",Font.CENTER_BASELINE,20));
txt9.setBounds(247,265,41,40);
txt9.setFont(new Font("A.C.M.E. Secret Agent",Font.CENTER_BASELINE,20));
txt10.setBounds(247,321,41,40);
txt10.setFont(new Font("A.C.M.E. Secret Agent",Font.CENTER_BASELINE,20));
txt11.setBounds(247,377,41,40);
txt11.setFont(new Font("A.C.M.E. Secret Agent",Font.CENTER_BASELINE,20));
txt12.setBounds(250,431,41,40);
txt12.setFont(new Font("A.C.M.E. Secret Agent",Font.CENTER_BASELINE,20));
txt13.setBounds(195,266,41,40);
txt13.setFont(new Font("A.C.M.E. Secret Agent",Font.CENTER_BASELINE,20));
txt14.setBounds(300,266,41,40);
txt14.setFont(new Font("A.C.M.E. Secret Agent",Font.CENTER_BASELINE,20));
txt15.setBounds(355,266,41,40);
txt15.setFont(new Font("A.C.M.E. Secret Agent",Font.CENTER_BASELINE,20));
//txt16.setBounds(358,215,41,40);
//txt16.setFont(new Font("A.C.M.E. Secret Agent",Font.CENTER_BASELINE,20));
txt17.setBounds(358,215,41,40);
txt17.setFont(new Font("A.C.M.E. Secret Agent",Font.CENTER_BASELINE,20));
txt18.setBounds(358,315,41,40);
txt18.setFont(new Font("A.C.M.E. Secret Agent",Font.CENTER_BASELINE,20));
lblImgAnimal1 = new JLabel();
ImageIcon elefante = new ImageIcon("imagens/elefante.gif");
lblImgAnimal1.setIcon(elefante);
lblImgAnimal1.setBounds(200,480,160,115);
this.add(lblImgAnimal1);
lblImgAnimal2 = new JLabel();
ImageIcon gato = new ImageIcon("imagens/gato.gif");
lblImgAnimal2.setIcon(gato);
lblImgAnimal2.setBounds(40,220,160,115);
this.add(lblImgAnimal2);
lblImgAnimal3 = new JLabel();
ImageIcon boi = new ImageIcon("imagens/boi.gif");
lblImgAnimal3.setIcon(boi);
lblImgAnimal3.setBounds(400,150,160,115);
this.add(lblImgAnimal3);
lblImgAnimal4 = new JLabel();
ImageIcon cisne = new ImageIcon("imagens/cisne.gif");
lblImgAnimal4.setIcon(cisne);
lblImgAnimal4.setBounds(300,5,160,115);
this.add(lblImgAnimal4);
/*Imagem do Jogo
lblJogo = new JLabel();
ImageIcon jogo = new ImageIcon("imagens/CruzadasLV1.png");
lblJogo.setIcon(jogo);
lblJogo.setBounds(10,10,600,500);
this.add(lblJogo);*/
//Imagem no Jlabel do Fundo
lblImagem = new JLabel();
ImageIcon fundo = new ImageIcon("Palavras Cruzadas.jpg");
lblImagem.setIcon(fundo);
lblImagem.setSize(fundo.getIconWidth(),fundo.getIconHeight());
this.add(lblImagem);
txt1.addFocusListener(new FocusListener() {
public void focusLost(FocusEvent arg0) {
txt1.setCaretPosition(0);
}
public void focusGained(FocusEvent arg0) {
txt1.setCaretPosition(0);
}
});
txt2.addFocusListener(new FocusListener() {
public void focusLost(FocusEvent arg0) {
txt2.setCaretPosition(0);
}
public void focusGained(FocusEvent arg0) {
txt2.setCaretPosition(0);
}
});
txt3.addFocusListener(new FocusListener() {
public void focusLost(FocusEvent arg0) {
txt3.setCaretPosition(0);
}
public void focusGained(FocusEvent arg0) {
txt3.setCaretPosition(0);
}
});
txt4.addFocusListener(new FocusListener() {
public void focusLost(FocusEvent arg0) {
txt4.setCaretPosition(0);
}
public void focusGained(FocusEvent arg0) {
txt4.setCaretPosition(0);
}
});
txt5.addFocusListener(new FocusListener() {
public void focusLost(FocusEvent arg0) {
txt5.setCaretPosition(0);
}
public void focusGained(FocusEvent arg0) {
txt5.setCaretPosition(0);
}
});
txt6.addFocusListener(new FocusListener() {
public void focusLost(FocusEvent arg0) {
txt6.setCaretPosition(0);
}
public void focusGained(FocusEvent arg0) {
txt6.setCaretPosition(0);
}
});
txt7.addFocusListener(new FocusListener() {
public void focusLost(FocusEvent arg0) {
txt7.setCaretPosition(0);
}
public void focusGained(FocusEvent arg0) {
txt7.setCaretPosition(0);
}
});
txt8.addFocusListener(new FocusListener() {
public void focusLost(FocusEvent arg0) {
txt8.setCaretPosition(0);
}
public void focusGained(FocusEvent arg0) {
txt8.setCaretPosition(0);
}
});
txt9.addFocusListener(new FocusListener() {
public void focusLost(FocusEvent arg0) {
txt9.setCaretPosition(0);
}
public void focusGained(FocusEvent arg0) {
txt9.setCaretPosition(0);
}
});
txt10.addFocusListener(new FocusListener() {
public void focusLost(FocusEvent arg0) {
txt10.setCaretPosition(0);
}
public void focusGained(FocusEvent arg0) {
txt10.setCaretPosition(0);
}
});
txt11.addFocusListener(new FocusListener() {
public void focusLost(FocusEvent arg0) {
txt11.setCaretPosition(0);
}
public void focusGained(FocusEvent arg0) {
txt11.setCaretPosition(0);
}
});
txt12.addFocusListener(new FocusListener() {
public void focusLost(FocusEvent arg0) {
txt12.setCaretPosition(0);
}
public void focusGained(FocusEvent arg0) {
txt12.setCaretPosition(0);
}
});
txt13.addFocusListener(new FocusListener() {
public void focusLost(FocusEvent arg0) {
txt13.setCaretPosition(0);
}
public void focusGained(FocusEvent arg0) {
txt13.setCaretPosition(0);
}
});
txt14.addFocusListener(new FocusListener() {
public void focusLost(FocusEvent arg0) {
txt14.setCaretPosition(0);
}
public void focusGained(FocusEvent arg0) {
txt14.setCaretPosition(0);
}
});
txt15.addFocusListener(new FocusListener() {
public void focusLost(FocusEvent arg0) {
txt15.setCaretPosition(0);
}
public void focusGained(FocusEvent arg0) {
txt15.setCaretPosition(0);
}
});
/*txt16.addFocusListener(new FocusListener() {
public void focusLost(FocusEvent arg0) {
txt16.setCaretPosition(0);
}
public void focusGained(FocusEvent arg0) {
txt16.setCaretPosition(0);
}
});*/
txt17.addFocusListener(new FocusListener() {
public void focusLost(FocusEvent arg0) {
txt17.setCaretPosition(0);
}
public void focusGained(FocusEvent arg0) {
txt17.setCaretPosition(0);
}
});
txt18.addFocusListener(new FocusListener() {
public void focusLost(FocusEvent arg0) {
txt18.setCaretPosition(0);
}
public void focusGained(FocusEvent arg0) {
txt18.setCaretPosition(0);
}
});
/*txt19.addFocusListener(new FocusListener() {
public void focusLost(FocusEvent arg0) {
txt19.setCaretPosition(0);
}
public void focusGained(FocusEvent arg0) {
txt19.setCaretPosition(0);
}
});
txt20.addFocusListener(new FocusListener() {
public void focusLost(FocusEvent arg0) {
txt20.setCaretPosition(0);
}
public void focusGained(FocusEvent arg0) {
txt20.setCaretPosition(0);
}
});*/
//eventos dos botões
btnSair.addActionListener(
new ActionListener()
{
public void actionPerformed(ActionEvent event)
{
frmSair Sair =new frmSair();
Sair.setVisible(true);
}
}
);
btnVerificar.addActionListener(
new ActionListener()
{
public void actionPerformed(ActionEvent event)
{
//Cisne
if(txt1.getText().equalsIgnoreCase("c")){
pontuacao = pontuacao + 1;
txt1.setBackground(Color.GREEN);
}else{
txt1.setBackground(Color.RED);
pontuacao = pontuacao - 1;
}
if(txt2.getText().equalsIgnoreCase("i")){
pontuacao = pontuacao + 1;
txt2.setBackground(Color.GREEN);
}else{
txt2.setBackground(Color.RED);
pontuacao = pontuacao - 1;
}
if(txt3.getText().equalsIgnoreCase("s")){
pontuacao = pontuacao + 1;
txt3.setBackground(Color.GREEN);
}else{
txt3.setBackground(Color.RED);
pontuacao = pontuacao - 1;
}
if(txt4.getText().equalsIgnoreCase("n")){
pontuacao = pontuacao + 1;
txt4.setBackground(Color.GREEN);
}else{
pontuacao = pontuacao - 1;
txt4.setBackground(Color.RED);
}
if(txt5.getText().equalsIgnoreCase("e")){
pontuacao = pontuacao + 1;
txt5.setBackground(Color.GREEN);
}else{
txt5.setBackground(Color.RED);
pontuacao = pontuacao - 1;
}
//Risca palavra Cisne
if(txt1.getText().equalsIgnoreCase("c") && txt2.getText().equalsIgnoreCase("i") && txt3.getText().equalsIgnoreCase("s") && txt4.getText().equalsIgnoreCase("n") && txt5.getText().equalsIgnoreCase("e")){
lblAnimal3.setText("<html><strike>Cisne ");
}else{
lblAnimal3.setText("<html>Cisne ");
}
//Elefante
if(txt6.getText().equalsIgnoreCase("l")){
pontuacao = pontuacao + 1;
txt6.setBackground(Color.GREEN);
}else{
txt6.setBackground(Color.RED);
pontuacao = pontuacao - 1;
}
if(txt7.getText().equalsIgnoreCase("e")){
pontuacao = pontuacao + 1;
txt7.setBackground(Color.GREEN);
}else{
txt7.setBackground(Color.RED);
pontuacao = pontuacao - 1;
}
if(txt8.getText().equalsIgnoreCase("f")){
pontuacao = pontuacao + 1;
txt8.setBackground(Color.GREEN);
}else{
txt8.setBackground(Color.RED);
pontuacao = pontuacao - 1;
}
if(txt9.getText().equalsIgnoreCase("a")){
pontuacao = pontuacao + 1;
txt9.setBackground(Color.GREEN);
}else{
txt9.setBackground(Color.RED);
pontuacao = pontuacao - 1;
}
if (txt10.getText().equalsIgnoreCase("n")){
pontuacao = pontuacao + 1;
txt10.setBackground(Color.GREEN);
}else{
txt10.setBackground(Color.RED);
pontuacao = pontuacao - 1;
}
if (txt11.getText().equalsIgnoreCase("t")){
pontuacao = pontuacao + 1;
txt11.setBackground(Color.GREEN);
}else{
txt11.setBackground(Color.RED);
pontuacao = pontuacao - 1;
}
if (txt12.getText().equalsIgnoreCase("e")){
pontuacao = pontuacao + 1;
txt12.setBackground(Color.GREEN);
}else{
txt12.setBackground(Color.RED);
pontuacao = pontuacao - 1;
}
//Risca palavra elefante
if(txt5.getText().equalsIgnoreCase("e") && txt6.getText().equalsIgnoreCase("l") && txt7.getText().equalsIgnoreCase("e") && txt8.getText().equalsIgnoreCase("f") && txt9.getText().equalsIgnoreCase("a") && txt10.getText().equalsIgnoreCase("n") && txt11.getText().equalsIgnoreCase("t") && txt12.getText().equalsIgnoreCase("e")){
lblAnimal1.setText("<html><strike>Elefante ");
}else{
lblAnimal1.setText("<html>Elefante ");
}
//Gato
if(txt13.getText().equalsIgnoreCase("g")){
pontuacao = pontuacao + 1;
txt13.setBackground(Color.GREEN);
}else{
txt13.setBackground(Color.RED);
pontuacao = pontuacao - 1;
}
if(txt14.getText().equalsIgnoreCase("t")){
pontuacao = pontuacao + 1;
txt14.setBackground(Color.GREEN);
}else{
txt14.setBackground(Color.RED);
pontuacao = pontuacao - 1;
}
if(txt15.getText().equalsIgnoreCase("o")){
pontuacao = pontuacao + 1;
txt15.setBackground(Color.GREEN);
}else{
txt15.setBackground(Color.RED);
pontuacao = pontuacao - 1;
}
//Risca palavra Gato
if(txt13.getText().equalsIgnoreCase("g") && txt9.getText().equalsIgnoreCase("a") && txt14.getText().equalsIgnoreCase("t") && txt15.getText().equalsIgnoreCase("o")){
lblAnimal2.setText("<html><strike>Gato ");
}else{
lblAnimal2.setText("<html>Gato ");
}
//Boi
if(txt17.getText().equalsIgnoreCase("b")){
pontuacao = pontuacao + 1;
txt17.setBackground(Color.GREEN);
}else{
txt17.setBackground(Color.RED);
pontuacao = pontuacao - 1;
}
if(txt18.getText().equalsIgnoreCase("i")){
pontuacao = pontuacao + 1;
txt18.setBackground(Color.GREEN);
}else{
txt18.setBackground(Color.RED);
pontuacao = pontuacao - 1;
}
//Risca Palavra Boi
if(txt17.getText().equalsIgnoreCase("b") && txt15.getText().equalsIgnoreCase("o") && txt18.getText().equalsIgnoreCase("i")){
lblAnimal4.setText("<html><strike>Boi ");
}else{
lblAnimal4.setText("<html>Boi ");
}
//Verificação sem pontuação
/*if (txt1.getBackground().equals(Color.GREEN) && txt2.getBackground().equals(Color.GREEN) && txt3.getBackground().equals(Color.GREEN) && txt4.getBackground().equals(Color.GREEN) && txt5.getBackground().equals(Color.GREEN) && txt6.getBackground().equals(Color.GREEN) && txt7.getBackground().equals(Color.GREEN) && txt8.getBackground().equals(Color.GREEN) && txt9.getBackground().equals(Color.GREEN) && txt10.getBackground().equals(Color.GREEN) && txt11.getBackground().equals(Color.GREEN) && txt12.getBackground().equals(Color.GREEN) && txt13.getBackground().equals(Color.GREEN) && txt14.getBackground().equals(Color.GREEN) && txt15.getBackground().equals(Color.GREEN)&& txt17.getBackground().equals(Color.GREEN)){
JOptionPane.showMessageDialog(null, "Parabéns Você venceu o jogo!");
}else{
JOptionPane.showMessageDialog(null, "Tem alguma coisa errada aí!");
}*/
//Verificação com pontuação
if(pontuacao >= 15){
JOptionPane.showMessageDialog(null, "Você Ganhaste!");
JOptionPane.showMessageDialog(null, "Parabéns! Sua pontuação foi: " +pontuacao);
level1 = 1;
System.out.println("Variavel de verificação de level recebe mais um " +level1);
frmFimDoJogo GameOver = new frmFimDoJogo();
GameOver.setVisible(true);
}else{
System.out.println("Pontos até agora: " +pontuacao);
JOptionPane.showMessageDialog(null, "Sua pontuação foi: " +pontuacao);
JOptionPane.showMessageDialog(null, "Falta pouco, tente novamente");
pontuacao = 0;
}
}});
btnAjuda.addActionListener(
new ActionListener()
{
public void actionPerformed(ActionEvent event)
{
frmAjuda ajuda = new frmAjuda();
ajuda.setVisible(true);
}});
btnNovoJogo.addActionListener(
new ActionListener()
{
public void actionPerformed(ActionEvent event)
{
}});
btnEstatisticas.addActionListener(
new ActionListener()
{
public void actionPerformed(ActionEvent event)
{
frmEstatisticas frame = new frmEstatisticas();
frame.setVisible(true);
}});
}}
[/code]
frmFimDoJogo:
[code]import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.text.ParseException;
import java.util.logging.Level;
import javax.swing.*;
public class frmFimDoJogo extends JDialog{
private JButton btnJogarNovamente, btnProximoLevel, btnSair;
private JLabel lblAviso, lblFundo;
Font f = new Font("A.C.M.E. Secret Agent",Font.BOLD,16);
Font g = new Font("A.C.M.E. Secret Agent",Font.BOLD,11);
public frmFimDoJogo(){
//super ("Atenção!");
this.setSize(503, 344);
this.setLayout(null);
this.setLocationRelativeTo(null);
this.setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
this.setResizable(false);
this.setUndecorated(true);
this.setModal(true);
lblAviso = new JLabel("O que você quer fazer agora?");
lblAviso.setBounds(90, 170, 350, 30);
lblAviso.setFont(f);
add(lblAviso);
btnJogarNovamente = new JButton("Jogar Novamente");
btnJogarNovamente.setBounds(50,250,180,30);
btnJogarNovamente.setFont(g);
add(btnJogarNovamente);
btnProximoLevel = new JButton("Próxima Fase");
btnProximoLevel.setBounds(300,250,150,30);
btnProximoLevel.setFont(g);
add(btnProximoLevel);
btnSair = new JButton("Sair do Jogo");
btnSair.setBounds(190, 300, 150, 30);
btnSair.setFont(g);
add(btnSair);
lblFundo = new JLabel (new ImageIcon("imagens/frmFimDoJogo.png"));
lblFundo.setBounds (0, 0, 503, 344);
add(lblFundo);
btnProximoLevel.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent event)
{
/*frmPalavrasCruzadasLV1facil frm = new frmPalavrasCruzadasLV1facil();
if(frm.level1 == 1){
JOptionPane.showMessageDialog(null, frm.level1);
frmPalavrasCruzadasLV2facil level2 = new frmPalavrasCruzadasLV2facil();
level2.setVisible(true);
setVisible(false);
}*/
}
});
btnSair.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
frmSair sair = new frmSair();
sair.setVisible(true);
setVisible(false);
}
});
btnJogarNovamente.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent event)
{
}
});
}
}
[/code]
vlw õ/