Search code examples
javajoptionpane

Unable to close one frame on the click of a button


The click of the button should make the current form invisible but nothing happens.Can anyone help me with this

if(e.getSource = b5) {
    int r = JOptionPane.showConfirmDialog(null, "Exit", "Exit?", JOptionPane.YES_NO_OPTION);

    if(r == JOptionPane.YES_OPTION) {
        encoder cc= new encoder() // this is the frame i am currently working in
        cc.setVisible(false);     // this should make the form invisible but that is not   happening
        cc.dispose();
    }
}

please help


Solution

  • You are creating new encoder and try to make it invisible and dispose right away. This is never made visible, so making it invisible makes no sense to me.