setLocation (AWT)

Discussion in 'Java' started by Jack, Nov 5, 2005.

  1. Jack

    Jack Guest

    Please compile the following code with Javac.
    Look at the objects in your browser and you will see that they are not at
    the right locations.
    Why?
    can you see what is wrong with setLocation?


    import java.awt.*;
    import java.applet.Applet;

    public class ListSimpleTest extends Applet {
    public void init() {
    List list = new List(5, false);
    list.add("Seattle");
    list.add("Washington");
    list.add("New York");
    list.add("Chicago");
    list.add("Miami");
    list.add("San Jose");
    list.add("Denver");
    add(list);

    list.setSize(400, 420);

    list.setName("This is a name.");

    int height = list.getHeight();
    int width = list.getWidth();

    TextField f1 = new TextField("1111");
    f1.setLocation(10, 10);
    add(f1);

    TextField f2 = new TextField("1111");
    f2.setLocation(20, 20);
    add(f2);

    TextField f3 = new TextField("1111");
    f3.setLocation(30, 30);
    add(f3);

    TextField f4 = new TextField("1111");
    f4.setLocation(80, 80);
    add(f4);

    f1.setText(Integer.toString(height));
    f2.setText(list.getName());

    f3.setText(Integer.toString(f2.getX()));
    f4.setText(Integer.toString(f2.getY()));

    //http://java.sun.com/developer/onlineTraining/awt/contents.html#AWTScrollbar
    }
    }
     
    Jack, Nov 5, 2005
    #1
    1. Advertising

  2. Jack

    Benji Guest

    Jack, while high on whiteboard markers, wrote:
    > can you see what is wrong with setLocation?


    what's wrong is that you didn't take the advice already given to you and
    just reposted your question. =P

    --
    Of making better designs there is no end,
    and much refactoring wearies the body.
     
    Benji, Nov 5, 2005
    #2
    1. Advertising

  3. Jack

    Jack Guest

    go away
    pssshhhhh pssssshhhh

    "Benji" <> wrote in message
    news:dkhm28$l0o$...
    > Jack, while high on whiteboard markers, wrote:
    >> can you see what is wrong with setLocation?

    >
    > what's wrong is that you didn't take the advice already given to you and
    > just reposted your question. =P
    >
    > --
    > Of making better designs there is no end,
    > and much refactoring wearies the body.
     
    Jack, Nov 5, 2005
    #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. Robert Mark Bram
    Replies:
    2
    Views:
    6,031
    Robert Mark Bram
    Dec 11, 2003
  2. Jack

    setLocation does not work

    Jack, Nov 4, 2005, in forum: Java
    Replies:
    9
    Views:
    9,794
    Andrew Thompson
    Nov 5, 2005
  3. asd
    Replies:
    3
    Views:
    7,739
    Knute Johnson
    Feb 7, 2007
  4. middaycrisis
    Replies:
    0
    Views:
    1,547
    middaycrisis
    Nov 11, 2007
  5. Icarus
    Replies:
    5
    Views:
    619
    Icarus
    Aug 3, 2008
Loading...

Share This Page