The Artima Developer Community
Sponsored Link

Java Answers Forum
JPanel problem

2 replies on 1 page. Most recent reply: Oct 7, 2003 12:41 PM by anugu

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 2 replies on 1 page
Josh

Posts: 1
Nickname: neophyte46
Registered: Oct, 2003

JPanel problem Posted: Oct 2, 2003 7:27 AM
Reply to this message Reply
Advertisement
Hi guys,
Basically I have a base JPanel class that extends JPanel, i.e 'public class basePanel extends JPanel'
in this class I created a new panel and added some stuff to it.

Now inside another class, I wanted to add this basePanel to the center panel in my main class. So I instantiated the basePanel class (created an new instance of that class) and tried adding it to the centerPanel.

BasePanel bPanel = new BasePanel();
centerPanel.add(basePanel);

The thing is, when I run my app nothing appears in the center panel. I have tried removing the center panel before adding the base panel and then adding the center panel to the pane again but have had no luck. Any help would be much appreciated....

/*
Josh
*/


mausam

Posts: 243
Nickname: mausam
Registered: Sep, 2003

Re: JPanel problem Posted: Oct 7, 2003 2:28 AM
Reply to this message Reply
code plz...
how any one can tell wat is wrong?

anugu

Posts: 1
Nickname: asr
Registered: Oct, 2003

Re: JPanel problem Posted: Oct 7, 2003 12:41 PM
Reply to this message Reply
If a component has been added to a container that has been displayed, validate must be called on that container to display the new component. If multiple components are being added, you can improve efficiency by calling validate only once, after all the components have been added.

http://java.sun.com/j2se/1.4.2/docs/api/java/awt/Container.html#add(java.awt.Component)

Flat View: This topic has 2 replies on 1 page
Topic: package import. Previous Topic   Next Topic Topic: OO Books using Java

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use