Hello i have this little program here, what i would like to happen is when i press the login button it makes that dialog dissapear and open a new frame. I can make that happen but i can't make the Dialog dissapear.
could someone please say what i have to change i my code here so it will work?
import java.awt.*; import java.awt.event.*; import javax.swing.*; import java.io.*; public class Bank { public final JDialog dialog = new JDialog(); public static void main(String [] args) { // JDialog dialog = new JDialog(); dialog.setDefaultCloseOperation(JDialog.HIDE_ON_CLOSE); dialog.setLayout(new FlowLayout()); dialog.setSize(new Dimension(300, 159)); dialog.setTitle("Login"); //Button JButton login = new JButton(); login.setText("Login"); //North dialog.setLayout(new BorderLayout()); JPanel north = new JPanel(new GridLayout(3, 3)); north.add(new JLabel ("Username: ")); north.add(new JTextField()); north.add(new JLabel ("Password: ")); north.add(new JTextField()); north.add(new JButton("Opret")); north.add(login); login.addActionListener(new login()); dialog.add(north, BorderLayout.NORTH); dialog.setVisible(true); // action center login.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e){ dialog.setVisible(false); } }); }