I see a couple of problems, but the most likely one is

add(BorderLayout.CENTER, getPanel1());

That should be

add( getPanel1( ), BorderLayout.CENTER );


Also the set size in init should probably be setBounds.

 
on 2/12/03 8:23 AM, Patrick Li at [EMAIL PROTECTED] wrote:

> Ok, here is the snipet of code. There is no problem with show, visible
> or adding to the applet. I can see the panel itself. I can also see all
> components when the hardcoded boundaries are specified with everything
> else the same. It is the first time I am trying LayoutManagers, so I
> suspect the problem occurs there. Also, please note that I am painting
> onto the applet itself, not to any dialogs.
> 
> I am simplifying the code here but the overal procedure is exactly the
> same.
> 
> public class MyApplet extends Applet {
> private Label ivjlblCountry = null;
> ....
> }
> 
> public void init() {
> try {
> setLayout(new BorderLayout(15,15));
> setSize(x,y,width,height);
> ... // populate data
> add(BorderLayout.CENTER, getPanel1());
> } catch (java.lang.Throwable ivjExc) {
> handleException(ivjExc);
> }
> }
> 
> private java.awt.Panel getPanel1() {
> if (ivjPanel1 == null) {
> try {
> ivjPanel1 = new java.awt.Panel();
> ivjPanel1.setLayout(new
> FlowLayout(FlowLayout.CENTER, 15, 15));
> ivjPanel1.setBounds(x,y,width,height);    // this
> is the same size as the parent
> ivjPanel1.add(getlblCountry());        // Each
> component is created as needed
> ...
> ivjPanel1.setBackground(Color.red);
> } catch (java.lang.Throwable ivjExc) {
> handleException(ivjExc);
> }
> }
> return ivjPanel1;
> }
> 
> // All individual component getters looks like the following.
> 
> private java.awt.Label getlblCountry() {
> if (ivjlblCountry == null) {
> try {
> ivjlblCountry = new java.awt.Label();
> // IF I UNCOMMENT THE FOLLOWING LINE, THEN THE
> COMPONENT SHOWS UP.
> //            ivjlblCountry.setBounds(x1,y1,w1,h1);
> ivjlblCountry.setText(COUNTRY_LABEL);
> } catch (java.lang.Throwable ivjExc) {
> handleException(ivjExc);
> }
> }
> return ivjlblCountry;
> }
> 
> What did I do wrong?
> 
> Patrick
> 
> -----Original Message-----
> From: Rich Burgis [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, February 12, 2003 10:32 AM
> To: jdjlist
> Subject: [jdjlist] RE: AWT components' platform dependency
> 
> 
> Could you post the code? That would make it much easier to figure out.
> 
> Also the issues relating to Frames, show and pack are irrelevant to the
> question for an applet. (Not that you can't use a Frame, but you
> probably 
> aren't since the Applet serves the purpose)
> 
> 
> ---
> You are currently subscribed to jdjlist as: [EMAIL PROTECTED]
> To unsubscribe send a blank email to [EMAIL PROTECTED]
> 


---
You are currently subscribed to jdjlist as: [EMAIL PROTECTED]
To unsubscribe send a blank email to [EMAIL PROTECTED]

Reply via email to