0

please help me how to close the window.
code:

    JButton quit = new JButton();

    public Mainmenu() {
        setLayout(new FlowLayout());

        Icon quitb = new ImageIcon(getClass().getResource("quit.jpg"));
        quit = new JButton(quitb);
        add(quit);

        quit.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {

            }
        });
3
Contributors
2
Replies
11
Views
3 Years
Discussion Span
Last Post by mKorbel
0

depends on....

  • if current parent JFrame/JDialog/JWindow for JButton quit = new JButton(); or not (not possible to suggest something based on your code and description),

  • if yes, then don't extend JFrame/JDialog/JWindow, create this Object as local variable, use this variable e.g. myWindow.setVisible(false) btw equals for JVM resources setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE/HIDE_ON_CLOSE) at runtime, you can to re_use this window for another action (myWindow.setVisible(true))

Edited by mKorbel

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.