• Post Reply Bookmark Topic Watch Topic
  • New Topic

GridbagLayout gridy not working

 
john mcallister
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello I'm trying to make a simple window that displays 5 text fields on x number of rows, depending on what I set x to. Attempting to do this with GridBagLayout but I can't seem to get a new row started. The closest I can get is to repeat the same fields on the same row. I'm trying to modify the row by putting the code in a loop and setting gridy = i, that way each iteration should place the code lower than the first. I'm new with GridBagLayout so I'm probably missing something simple, forgive me if that's the case. The constructor with the loop is below. I've commented out code that doesn't seem to work but left the gridx and gridy.
 
K. Tsang
Bartender
Posts: 3610
16
Firefox Browser Java Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch.

First off, I'm not a fan of GrigBagLayout. But anyway, what the "depths" variable in the for loop?

You said your current approach displays the 5 fields on single row. Question is does the for loop iterate after each field is added? In another words, each iteration you want the for loop only add 1 field right?

Think there is no GUI components and you have "2" variables x and y. Should you need 2 for loops, each looping each variable?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!