Results 1 to 5 of 5
Like Tree1Likes
  • 1 Post By DarrylBurke

Thread: GridBagLayout-forcing content left.

  1. #1
    Mapisto is offline Senior Member
    Join Date
    Dec 2011
    Posts
    102
    Rep Power
    0

    Default GridBagLayout-forcing content left.

    Before troubling you, I've searched information about this and found some1 else who had the same problem.

    One of the guys who answered him proposed a solution that worked (I've tried it myself).

    The thing is, I couldn't understand what exactly the change in the code did to make it work!

    here's the link:
    gridBagLayout anchor ... wanna move all components to top left

    Take a look at reply #12 - the guy added "d" after declaring the c.weight=1

    Without the "d" it just won't work no matter what else I've tried, the content stayed in the middle.

    So what exactly this 'd' stands for? how does it help ?

    Thanks :)

  2. #2
    kammce's Avatar
    kammce is offline Senior Member
    Join Date
    Dec 2010
    Location
    California
    Posts
    194
    Rep Power
    4

    Default Re: GridBagLayout-forcing content left.

    Um, I am not sure yet, but I can tell you that, if you place a 'd' character after a number in Java, it will cast it as a double. Or something similar to that. For example:
    Java Code:
     double number = 1d;
    if you do
    Java Code:
     int number = 1d;
    you get an error saying lose of precision because the number is a double and you trying to fit it into an integer.
    Same goes with floats.

    Java Code:
     float number = 1f;
    Maybe, making the number a double precision primitive type makes the weight work.
    My API:
    Java Code:
    cat > a.out || cat > main.class

  3. #3
    Mapisto is offline Senior Member
    Join Date
    Dec 2011
    Posts
    102
    Rep Power
    0

    Default Re: GridBagLayout-forcing content left.

    Ye,
    I thought it maybe has something to do with that, because we use these letters for "printf".

    But now I've tried just writing 1 without 'd' and it worked! when I write 0 is doesn't work.

  4. #4
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,453
    Rep Power
    20

    Default Re: GridBagLayout-forcing content left.

    Quote Originally Posted by Mapisto View Post
    ... because we use these letters for "printf".
    That's an entirely different kettle of fish. Don't confuse them just because the same letter is used.

    Chapter*3.*Lexical Structure - go through the entire section.

    db
    Mapisto likes this.
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  5. #5
    kammce's Avatar
    kammce is offline Senior Member
    Join Date
    Dec 2010
    Location
    California
    Posts
    194
    Rep Power
    4

    Default Re: GridBagLayout-forcing content left.

    Quote Originally Posted by DarrylBurke View Post
    That's an entirely different kettle of fish. Don't confuse them just because the same letter is used.

    Chapter*3.*Lexical Structure - go through the entire section.

    db
    Thanks DarrylBurke. I have always wondered what those letters were called.
    My API:
    Java Code:
    cat > a.out || cat > main.class

Similar Threads

  1. Replies: 1
    Last Post: 04-27-2012, 04:47 AM
  2. GridBagLayout - forcing all components to stay on top
    By Serpenthelm in forum AWT / Swing
    Replies: 3
    Last Post: 01-05-2012, 07:52 PM
  3. Reversing dojo slider to make it slide from right to left rather left to right as giv
    By gurpreet.singh in forum JavaServer Pages (JSP) and JSTL
    Replies: 1
    Last Post: 05-05-2011, 02:49 PM
  4. square moves left and down but not up or left
    By natdizzle in forum AWT / Swing
    Replies: 3
    Last Post: 02-04-2011, 06:20 PM
  5. Replies: 16
    Last Post: 11-17-2010, 02:02 PM

Posting Permissions

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