Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Damned Container....

Reply
Thread Tools

Damned Container....

 
 
Nicolas
Guest
Posts: n/a
 
      08-03-2003
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)
 
Reply With Quote
 
 
 
 
Andreas Wollschlaeger
Guest
Posts: n/a
 
      08-03-2003
Nicolas wrote:
> 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

 
Reply With Quote
 
 
 
 
Wayne
Guest
Posts: n/a
 
      08-04-2003
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

Nicolas wrote:

> 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)


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Generics, damned if you do, damned if you don't Roedy Green Java 10 07-03-2007 08:22 PM
Damned red arrow won't go away! Captain Infinity Firefox 7 07-30-2005 03:38 PM
Damned DSL Computer Support 4 07-26-2005 07:27 PM
Damned attachment MayB Computer Support 4 12-19-2004 03:28 AM
"Heretic: City of the Damned" cheatsheet? Max Quordlepleen Computer Support 4 06-28-2003 04:32 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57