#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2013
    Posts
    74
    Rep Power
    2

    JTextField and JFrame




    the image above is a 300x300 JFrame, where does the X and Y coordiates really starts? because when i put JTextField(300) it lapses the JFrame. Thank you
  2. #2
  3. Contributing User
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Aug 2010
    Location
    Eastern Florida
    Posts
    3,713
    Rep Power
    348
    The JFrame has insets and borders that use some of the 300x300 space.
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2013
    Posts
    74
    Rep Power
    2
    Originally Posted by NormR
    The JFrame has insets and borders that use some of the 300x300 space.

    yeah, i know that. my question is where does this X and Y coordinates. okay, so what is the size of the box(not the textfield, the box colored gray) inside that JFrame? assuming setResizable(false);
  6. #4
  7. Contributing User
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Aug 2010
    Location
    Eastern Florida
    Posts
    3,713
    Rep Power
    348
    Do some experimenting by printing out the values of the properties of the JFrame and the JTextField to see what the values are so you will understand.

    Post some code with some questions about what you are trying to do.

    What are the X and Y values you refer to? Where are they used? Is there a method that uses them?
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2013
    Posts
    74
    Rep Power
    2
    Originally Posted by NormR
    Do some experimenting by printing out the values of the properties of the JFrame and the JTextField to see what the values are so you will understand.

    Post some code with some questions about what you are trying to do.

    What are the X and Y values you refer to? Where are they used? Is there a method that uses them?
    red rectangle as JTextField
    black rectangle as JFrame
    gray rectangle as space inside JFrame


    JFrame: setSize(300,300);
    now, set the size of the textfield to field.setBounds(0,0,299,30)
    X coordinate = 0
    Y coordinate = 0
    width = 299
    height = 30


    the JTextField over laps, why?
  10. #6
  11. Contributing User
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Aug 2010
    Location
    Eastern Florida
    Posts
    3,713
    Rep Power
    348
    If the frame's is 300 wide, then it can't contain a component that is 300 wide.
    The component needs to consider the insets used by the frame to see how much space it can use.

    BTW the x and y directions in your image are wrong. x is the horizontal and y the vertical
  12. #7
  13. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2013
    Posts
    74
    Rep Power
    2
    Originally Posted by NormR
    If the frame's is 300 wide, then it can't contain a component that is 300 wide.
    The component needs to consider the insets used by the frame to see how much space it can use.

    BTW the x and y directions in your image are wrong. x is the horizontal and y the vertical
    okay! question answered. Thank you JFrame is the one who has the size of 300,300 and not the space inside. i get it get it .i thought the JFrame will adjust to contain a space of 300,300. and about that X and Y, sorry :P didnt notice it.

IMN logo majestic logo threadwatch logo seochat tools logo