I am trying to make a menu item which when I click it makes a JInternalFrame visible. I created the JDesktopPane and added the JInternalFrame to it.
JInternalFrame neworder_jif;
public MainFrame() {
Login login = new Login(this, true);
login.setVisible(true);
initComponents();
//NEW ORDER JIF
desk.add(neworder_jif = new NewOrder());
neworder_jif.pack();
neworder_jif.setVisible(true);
}
As you can see, with this code the internal frame appears correctly but I want it to start invisible, but when I make
neworder_jif.setVisible(false);
on the constructor and create the action listener to when mouse clicked
private void new_order_menuMouseClicked(java.awt.event.MouseEvent evt) {
neworder_jif.setVisible(true);
}
it does not work, I click the menu item and nothing happens.
ANSWER
For those looking for the bug in this code I will explain how I fixed it: changed the event from MouseButtonClicked event created with NetBeans design editor to MouseButtonReleased.