Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

JPanel not visible

Status
Not open for further replies.

fatcodeguy

Programmer
Feb 25, 2002
281
CA
Hi, I have a JPanel with some widgets on it, which is suppose to open when I press a button. this is what my action listener looks like

button.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
myFrame.getContentPane().add(new myJPanel(myFrame));
}
});
The panel calls myFrame because it needs some of the objects defined in the owner pane.

Putting aside that the layout will be messed, I have setVisible(true) in the panel constructor, but I still can't see it when it constructs. Any suggestions? thanks
 
its difficult to say without seeing the class definition of your myJPanel class, but in my own experience JPanels tend to stay hidden if they havent had components added to them - maybe there is a problem with your constructor - are you trying to add components to it that have already been instantiated on your parent frame? Usually you will need to create duplicate objects rather than reutilize the existing components.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top