开发者

Issues with GridLayout

In my application i am looking to fill the JPanel with buttons generated dynamically. I am using GridBagLayout for that.

1.) When i setup the layout manager to fill just one row with many columns even if there is just one button it fills the entire area which is fine.

2.) In the case of same layout with one column and multiple row its is not filling the whole JPanel but it put the button on the top of the panel. I want to fill the button to fit the panel and i dont want to see any empty spaces.

1 and 2 are 2 different panels.

I wonder why is it doing to the second panel i was talking about when i use same kind of code for both. The code i am using is shown below.

left_panel.setLayout(new GridLayout(count, 1, 5, 5));

top_panel.setLayout(new GridLayout(1, count, 5, 5));

Here left_p开发者_StackOverflow中文版anel and top_panel are 2 JPanel


In this example, which uses GridLayout, the buttons fill the space available in both directions at each game level. You might compare your code to the code in resetGame().

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜