setBounds

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Kid Programmer
    New Member
    • Mar 2008
    • 176

    setBounds

    Hello guys. I just tried out using the setBounds method after looking at it in the Java API under JButton (though any other component should have it) and so anyways I tried it out in a simple little program. But no matter how much I change the parameters the button never changes. Why is this?
  • BigDaddyLH
    Recognized Expert Top Contributor
    • Dec 2007
    • 1216

    #2
    You should not explicitly set the bounds on any component. Rather, let the container's layout manager determine the components' bounds:

    This Swing Java Tutorial describes developing graphical user interfaces (GUIs) for applications and applets using Swing components

    Comment

    • sukatoa
      Contributor
      • Nov 2007
      • 539

      #3
      But no matter how much I change the parameters the button never changes. Why is this?
      You may set first the container's layout to null before you use setBounds....

      regards,
      sukatoa

      Comment

      • Kid Programmer
        New Member
        • Mar 2008
        • 176

        #4
        Originally posted by sukatoa
        You may set first the container's layout to null before you use setBounds....

        regards,
        sukatoa
        I just found that out yesterday. setBounds was very useful in getting the exact layout I wanted.

        Comment

        • JosAH
          Recognized Expert MVP
          • Mar 2007
          • 11453

          #5
          Originally posted by Kid Programmer
          I just found that out yesterday. setBounds was very useful in getting the exact layout I wanted.
          You shouldn't want that; think of different screen resolutions: your manual
          layout goes completely berzerk on them, layout managers won't.

          kind regards,

          Jos

          Comment

          • BigDaddyLH
            Recognized Expert Top Contributor
            • Dec 2007
            • 1216

            #6
            Originally posted by sukatoa
            You may set first the container's layout to null before you use setBounds....

            regards,
            sukatoa
            I recommend against doing that.

            Comment

            Working...