Results 1 to 6 of 6
  1. #1
    mensaFool is offline Member
    Join Date
    Sep 2009
    Posts
    8
    Rep Power
    0

    Default applet and dimension

    Hello -
    I was curious about a code quirk. So why in the world does:

    Dimension d = new Dimension();
    d.setSize(400,400);

    =!

    Dimension d = new Dimension();
    setSize(400, 400);


    What setSize method am I calling and why does my applet window size change? I would expect that in either instance, it would be 400x400.

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    here:
    Java Code:
    Dimension d = new Dimension();
    d.setSize(400,400);
    You're setting the size of a Dimension object, but what good does this do as this object is not related to your applet in any way.

    Here:
    Java Code:
    Dimension d = new Dimension();
    setSize(400, 400);
    You're creating a Dimension and ignoring it (might as well delete that first line as it's doing nothing), and then setting the size of the applet itself.

    I don't do applets much myself, but have found that often the size needs to be set by the HTML code that calls the applet. Again, I don't do much applet coding so this may be wrong.

  3. #3
    mensaFool is offline Member
    Join Date
    Sep 2009
    Posts
    8
    Rep Power
    0

    Default OK - Thanks for the reply

    I figured it was something that I was setting the height and width of the dimension object vs actually setting the size of the applet. where is the:

    Java Code:
    Applet.setSize(x,y);
    Method?

    also, what would the line

    Java Code:
     Dimension d = getSize();
    do?

  4. #4
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    What do you mean where is that method? If you look up Applet, you'll see that it inherits from Container which inherits from Component, and that Component has two setSize methods.

  5. #5
    mensaFool is offline Member
    Join Date
    Sep 2009
    Posts
    8
    Rep Power
    0

    Default

    Ahhhhhhh... ok. TY, I didn't notice the hierarchy. I was only using the Eclipse IDE Doc.

  6. #6
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

Similar Threads

  1. Replies: 5
    Last Post: 05-18-2009, 12:42 PM
  2. noob: two-dimension array
    By bobmasta5 in forum New To Java
    Replies: 5
    Last Post: 03-15-2009, 11:42 PM
  3. JPanel in agreement with dimension of pictures
    By KamilR in forum AWT / Swing
    Replies: 1
    Last Post: 04-28-2008, 07:38 AM
  4. Replies: 2
    Last Post: 04-27-2008, 07:51 PM
  5. Arraylist to a 2- dimension array conversion
    By mars123 in forum New To Java
    Replies: 1
    Last Post: 12-06-2007, 11:24 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •