Damned Container....

Discussion in 'Java' started by Nicolas, Aug 3, 2003.

  1. Nicolas

    Nicolas Guest

    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)
     
    Nicolas, Aug 3, 2003
    #1
    1. Advertising

  2. 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
     
    Andreas Wollschlaeger, Aug 3, 2003
    #2
    1. Advertising

  3. Nicolas

    Wayne Guest

    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)
     
    Wayne, Aug 4, 2003
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Luke Webber

    Too damned many jar files

    Luke Webber, Jun 7, 2006, in forum: Java
    Replies:
    9
    Views:
    485
    Dale King
    Jun 10, 2006
  2. Ben

    Strings, Strings and Damned Strings

    Ben, Jun 22, 2006, in forum: C Programming
    Replies:
    14
    Views:
    767
    Malcolm
    Jun 24, 2006
  3. Roedy Green
    Replies:
    10
    Views:
    683
    Roedy Green
    Jul 3, 2007
  4. Bob Martin
    Replies:
    0
    Views:
    88
    Bob Martin
    Jan 10, 2014
  5. Gene Heskett
    Replies:
    0
    Views:
    70
    Gene Heskett
    Jan 10, 2014
Loading...

Share This Page