Damned Container....

N

Nicolas

Maybe another problem of JPanel refresh....

In a JApplet, I have a big Panel, split in 3 other JPanel :
panelNorth, panelCentral, panelSouth

In the North, I have a few JButtons, in the Center, I want to put main
datas, in the South, I have a few JLabel

I have made a JButton who put another JPanel in panelCentral

The code linked to the event is :
MyDataPanel panel = new MyDataPanel( );
this.panelCentral.add(panel, java.awt.BorderLayout.CENTER);
System.out.println("Yop");

The problem is that when I click the Button, nothing appears except
"Yop" in the Java Console.

Yet when I push this code in the Constructor, everything is fine when
I start the Applet.
So I have tried many combinations of setVisible, paint and repaint,
nothing is good...

With a frame, I succeeded making a setContentPane(getContentPane( ) )
.. Is there a more logical and more efficient way with JPanel ???

Thanx a lot !
Nicolas (Sorry for my English)
 
A

Andreas Wollschlaeger

Nicolas said:
Maybe another problem of JPanel refresh....

In a JApplet, I have a big Panel, split in 3 other JPanel :
panelNorth, panelCentral, panelSouth

In the North, I have a few JButtons, in the Center, I want to put main
datas, in the South, I have a few JLabel

I have made a JButton who put another JPanel in panelCentral

The code linked to the event is :
MyDataPanel panel = new MyDataPanel( );
this.panelCentral.add(panel, java.awt.BorderLayout.CENTER);
System.out.println("Yop");

The problem is that when I click the Button, nothing appears except
"Yop" in the Java Console.

Yet when I push this code in the Constructor, everything is fine when
I start the Applet.
So I have tried many combinations of setVisible, paint and repaint,
nothing is good...

With a frame, I succeeded making a setContentPane(getContentPane( ) )
. Is there a more logical and more efficient way with JPanel ???

Thanx a lot !
Nicolas (Sorry for my English)

Try panelcentral.validate() - sorry, just an educated guess, HTH :)

Andreas
 
W

Wayne

Re: Components not showing up when added to JPanel:

I have two words of advice that may (or may not) help:

* Only one component can be put into a BorderLayout area at
a time. It is not defined what happens when you add a second
panel to the Center of a BorderLayout container. You didn't
include enough code to see if this is the problem though.

* A nifty developer aid is to set the background color of each
JPanel (and make them opaque) to different colors. That way
you can easily see what get's drawn and what doesn't. I think
you may find your big JPanel isn't big enough, and when that
happens the components in the center may not bet drawn. Try
this color idea; if indeed the new panel doesn't show, then try
making the outer container larger.

Hope this helps!

-Wayne
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top