Hi, I need to display a panel when I click on the menuitem of a frame(myFrame). I am using setVisible(true). It works.... but : The problem is that the panel doesn't get displayed unless I resize myFrame with the mouse. Similarly, when I click on another menuitem on the frame, the existing panel should disappear and another panel should appear. I am using myFrame.remove(panel1) and then myFrame.add(panel2) and setVisible property of panel2 set to true. It again works, but only after I resize the parent frame. Can anyone tell me why the changes don't appear instantly on the click, and what to do to remediate this ?? Ashu
This could be too simple a solution. Put the setvisible(true) after you add the panel to the frame. i.e frame.add(panel) ; frame.setvisible(true) ; As a thumb rule the setvisible should be set after you have added all the necessary components as well as set the frame size. Apologies if it doesn't work, Shilpa.
Joined: Dec 12, 2000
Try adding the panels before setting myFrame.setVisible(true). You probably don't need to add or remove the panels. Just set the panel1 or panel2 visibility true or false depending upon the menu item selected. Shilpa.
Joined: Nov 30, 2000
Thanks Shilpa, Actually I had aready done what u said ... but in the wrong way ... I had added the panel as well as setvisible(true) in the same event. It works fine if instanciate initially and then setvisible prop is used in the events. Thanks again Ashu