I am currently using Eclipse's drag and Drop feature, I have one application window which comes with JFrame by default and is able to `setVisible(false);` but my other frames/panel/window I have created with JPanel and with extending JFrame. 

Because of `extend` I am unable to `setVisible(false or true);` it has no effect at all on the window it still remains true.

My code :

```
private JPanel contentPane;

/**
 * Launch the application.
 */
public static void main(String[] args) {
    EventQueue.invokeLater(new Runnable() {
        public void run() {
            try {
                LibrarianMenu frame = new LibrarianMenu();
                frame.setVisible(true);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    });
}

public LibrarianMenu() {
    setTitle("Librarian");
    setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    setBounds(100, 100, 385, 230);
    contentPane = new JPanel();
    contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
    setContentPane(contentPane);
    contentPane.setLayout(null);
    .
    .
    . so on

```

Here I am trying to execute my button:

```
 btnLogout.addActionListener(
            new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    LibrarianMenu frame = new LibrarianMenu();
                    frame.setVisible(false);
                }
            });

```

Any solutions for it?