o cara malz pela demora em responder, mas eu estava sem net
vou colocar o codigo e explicar o erro
bom aqui em baixo tem 3 classes onde eu faço a chamada da classe menu na main e da menu e faço chamada da jogo,
fazer chamada da menu esta indo normal mas na hora de chamar a classe jogo não esta indo,
não se preocupe com as janelas pois ainda não as terminei, então meu foco e conseguir fazer a chama das telas,
e eu tenho outras ainda, então tenho que pular entre umas 3 ou 4 telas.
vlw pela ajuda t+
CLASS MAIN
import javax.swing.JOptionPane;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class RestaMain {
public static void main (String args[]){
RestaMenu rt = new RestaMenu();
RestaJogo tl = new RestaJogo();
RestaNome1 rn = new RestaNome1();
RestaDificuldade rd = new RestaDificuldade();
int jnj = JOptionPane.showConfirmDialog(null, "Gostaria de Iniciar o Jogo");
if (jnj == 0){
rt.RestaMenu();
//tl.RestaJogo();
//rn.RestaNome();
//rd.RestaDificuldade();
}else if (jnj == 1){
JOptionPane.showMessageDialog(null, "não aceita o jogo");
System.exit(0);
}else {
JOptionPane.showMessageDialog(null, "Jogo cancelado");
System.exit(0);
}
}
}
CLASSE RESTAMENU
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class RestaMenu extends JFrame implements ActionListener{
private String jog1;
private String jog2;
JButton bJ2 = new JButton("Contra outro Jogador");
JButton bComp = new JButton ("Contra o Computador");
JButton bCancel = new JButton ("Sair do Jogo");
public void RestaMenu(){
getContentPane().setLayout(new GridLayout(3,1,5,5));
bJ2.addActionListener(this);
bComp.addActionListener(this);
bCancel.addActionListener(this);
this.getContentPane().add(bJ2);
this.getContentPane().add(bComp);
this.getContentPane().add(bCancel);
setDefaultCloseOperation(EXIT_ON_CLOSE);
pack();
setLocation(450,325);
setVisible(true);
}
RestaJogo rt = new RestaJogo();
public void actionPerformed (ActionEvent e ){
if (e.getSource()==bJ2){
jog1 = JOptionPane.showInputDialog("Escolha o nome do primeiro jogador");
jog2 = JOptionPane.showInputDialog("Escolha o nome do segundo jogador");
int conf = JOptionPane.showConfirmDialog(null, "Confirme os nomes: \n" + jog1+"\n"+ jog2);
if (conf == 0){
this.setVisible(false);
rt.setVisible(true);
}else if (conf == 1){
}else {
JOptionPane.showMessageDialog(null, "Jogo cancelado");
System.exit(0);
}
}
if(e.getSource()==bComp){
String jogador1 = JOptionPane.showInputDialog("Escolha o nome do jogador");
JOptionPane.showConfirmDialog(null, "Confirme o nome do Jogador \n" + jogador1);
}
if(e.getSource()==bCancel){
JOptionPane.showMessageDialog(null, "Jogo Cancelado");
System.exit(0);
}
}
}
CLASSE RESTAJOGO
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class RestaJogo extends JFrame implements ActionListener {
private JTextArea taEditor;
private JTextField tfEntrada, tfPosicao;
JButton bInsert, bSair, bClear, bNum3;
Random random = new Random();
public void RestaJogo(){
setTitle("Demo TextArea");
setBackground(SystemColor.control);
JPanel p = new JPanel (new GridLayout(3,3,5,5));
p.add(bInsert = new JButton ("1"));
p.add(bSair = new JButton ("2"));
p.add(bNum3 = new JButton ("3"));
add(p,BorderLayout.LINE_START);
p = new JPanel(new FlowLayout(FlowLayout.RIGHT));
/*p.add(new JLabel("texto a inserir"));
p.add(tfEntrada = new JTextField(20));
p.add(tfPosicao = new JTextField(3));*/
p.add(bSair = new JButton ("Sair"));
add(p,BorderLayout.SOUTH);
p = new JPanel(new FlowLayout(FlowLayout.CENTER));
p.add(new JLabel("Jogador 1"));
p.add(new JLabel("Jogador 2"));
p.add(new JLabel("Numero Selecionado para o jogo"));
p.add( new JFormattedTextField(random.getRandom(37, 42)));
add(p,BorderLayout.NORTH);
taEditor = new JTextArea("",30,60);
JScrollPane sp = new JScrollPane(taEditor);
add(sp, BorderLayout.CENTER);
bInsert.addActionListener(this);
bSair.addActionListener(this);
bNum3.addActionListener(this);
//bClear.addActionListener(this);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
pack();
setVisible(true);
}
public void actionPerformed (ActionEvent e ){
if(e.getSource()==bSair)
System.exit(0);
}
}