Java application app [closed]

1

This code when pressed on the definicoes button opens a new window with an image, a line with text and also generates radio buttons, but the problem is that it creates another new window with the radio buttons and also doubles the JFrame that contains all the buttons, and I do not want to duplicate JFrame . What I wanted was to show the image, the text and the radio buttons all in the same new window. Can you do that? Keeping clear and open the JFrame that has this button definicoes and also has other buttons, etc.

 if (definicoesBtn == e.getSource()) // botao definicoes premido
 {
     window = new JFrame(" Jogo da Memoria - Definicoes:");
     window.setLayout(new BorderLayout());  

     JLabel label3 = new JLabel(" Definicoes: ");           
     window.add("Center", label3);
     window.resize(300,300);
     window.show();                         
     ImageIcon img = new ImageIcon("definicoes.jpg");
     int altura = img.getIconHeight();  
     int largura = img.getIconWidth(); 
     JLabel label = new JLabel(img);    
     window.add(label, BorderLayout.NORTH);

     MemoryGame formulario1=new MemoryGame(); // cria os radiobutton
     formulario1.setBounds(0,0,300,200);
     formulario1.setVisible(true);

     window.pack();  
     window.setVisible(true); 
 }

My main class is this in the first few lines of code:

public class MemoryGame extends JFrame implements ActionListener, ChangeListener
{
    private JCheckBox check1,check2,check3; // declaracao dos checkbutoes
    //...  
    private JFrame window = new JFrame("Jogo da Memoria");
    // Jframe com todos os botoes janela inicial declarei em MemoryGame()

    public MemoryGame() {  
        setLayout(null);
        check1=new JCheckBox("Inglés");
        check1.setBounds(10,10,150,30);
        check1.addChangeListener(this);
        add(check1);
        check2=new JCheckBox("Francés");
        check2.setBounds(10,50,150,30);
        check2.addChangeListener(this);        
        add(check2);
        check3=new JCheckBox("Alemán");
        check3.setBounds(10,90,150,30);
        check3.addChangeListener(this);        
        add(check3);

And also the function:

 public void stateChanged(ChangeEvent e){
    String cad="";
    if (check1.isSelected()==true) {
        cad=cad+"Inglés-";
    }
    if (check2.isSelected()==true) {
        cad=cad+"Francés-";
    }
    if (check3.isSelected()==true) {
        cad=cad+"Alemán-";
    }
    setTitle(cad);
}

Something must be wrong or incomplete, so I need help solving or remedying the code.

    
asked by anonymous 16.04.2015 / 14:06

0 answers