Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Why does GridLayout ignore the number of columns I specify?

  1. #1
    Junior Member
    Join Date
    Sep 2011
    Posts
    21
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Why does GridLayout ignore the number of columns I specify?

    I'm learning how to use layout managers, and I've come to learn that when the GridLayout constructor is set with both the number of rows and columns to non-zero values, it ignores the number of columns I specify and re-sizes them to (numComponents + numRows - 1)/numRows. Setting the number of rows or columns to 0 fixes this orientation problem easily enough, but I am still left wondering what the purpose is for this. Why would GridLayout ignore the parameters of its own constructor? If I want 6 rows and 7 columns I should be able to call new GridLayout(6, 7) and not have to worry about the number of components I have changing the number of columns on me. I just don't see the point, why is GridLayout set up this way?


  2. #2
    Member
    Join Date
    May 2011
    Location
    west palm beach, FL
    Posts
    189
    My Mood
    Tired
    Thanks
    41
    Thanked 11 Times in 10 Posts

    Default Re: Why does GridLayout ignore the number of columns I specify?

    it is my understanding that when you set it to 0 it tells it that you dont know how many you will have instead of going back when you need to add another row or column and changing the numbers...i too am having trouble with layout managers so i cant really answer the other parts of the question cause i have trouble with that too lol

    i believe you can only put 1 component in each piece of the grid but im not positive so maybe someone else could explain better

Similar Threads

  1. how to ignore upper and lower case
    By mohamed_saleh2012 in forum Java Theory & Questions
    Replies: 1
    Last Post: March 10th, 2012, 03:49 PM
  2. Which files do I ignore in my version control?
    By ChristopherLowe in forum Android Development
    Replies: 1
    Last Post: January 5th, 2012, 11:39 PM
  3. How do I make this Palindrome tester ignore punctuation?
    By trogan234 in forum What's Wrong With My Code?
    Replies: 2
    Last Post: October 3rd, 2011, 05:43 AM
  4. [SOLVED] Tabbing columns
    By SnarkKnuckle in forum What's Wrong With My Code?
    Replies: 4
    Last Post: January 24th, 2011, 10:50 PM