Hi,

Sorry about the typos. The syntax for add() method seems to work both
ways. I also used setLocation() with setSize() for the boundary which I
didn't show in the snipet. The color is for test purposes only. If I run
this simple program below, it works. However, as soon as I put it into
my project, it stops working. I think I have to broaden the context a
little. This applet is painted on top of another applet which holds some
other common graphical components for a set of dialogs. 

I will try to create a snipet of container applet now for further
testing.

Patrick
-----Original Message-----
From: Me [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, February 12, 2003 4:25 PM
To: jdjlist
Subject: [jdjlist] RE: AWT components' platform dependency


Well I copied your code into my compiler and fixed the errors (mostly
due to
reducing it to a sample I expect. There were a lot of extraneous }'s)

I fixed the add as I mentioned in the previous email and the setBounds
ending up with 

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.FlowLayout;
import java.awt.Label;
import java.awt.Panel;

public class testli1 extends java.applet.Applet {
   private static final String COUNTRY_LABEL = "Canada";

   private Label ivjlblCountry = null;
   private int x = 20;
   private int y = 20;
   private int width = 20;
   private int height = 20;
   Panel ivjPanel1;
   
public void init() {
      setLayout(new BorderLayout(15,15));
      setBounds(x,y,width,height);
  
      add(BorderLayout.CENTER, getPanel1());
   }

private java.awt.Panel getPanel1() {
   if (ivjPanel1 == null) {
         ivjPanel1 = new java.awt.Panel();
         ivjPanel1.setLayout(new
                             FlowLayout(FlowLayout.CENTER, 15, 15));
         ivjPanel1.setBounds(x,y,width,height);    // this
            ivjPanel1.add(getlblCountry());        // Each

            ivjPanel1.setBackground(Color.red);
      }
   
   return ivjPanel1;
}
// All individual component getters looks like the following.
private java.awt.Label getlblCountry() {
   if (ivjlblCountry == null) {
         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);
      }
   
   return ivjlblCountry;
}
}

The layout is nasty, but I really don't have the time to clean it up.

This shows an applet colored red with the word Canada at the top. From
what
I can see that looks right, so it may have been either the setSize or
the
add that was at fault.


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