0

I am using the BoxLayout Manager to fit other jpanels horizontally. On each one of those panels contained inside of the boxlayout, is another box layout that lays out jbuttons vertically. Here is a visual image.

my layout

I would like to be able to add borders between each set of buttons, as well as add a top button that says what each value in the column is. The borders don't seem that hard, but I am not sure if it is even possible to add a column header with the current layout manager I have.

Do I need to switch layout managers, or is there a way to add column headers to each panel? Glue seems like an idea, but I am not sure how to position the header at the very top, while still centering the other buttons.

4

1 回答 1

2

我需要切换布局管理器,还是有办法将列标题添加到每个面板?胶水似乎是一个想法,但我不确定如何将标题放置在最顶部,同时仍使其他按钮居中。

用a 包裹JPanel每一列,BorderLayout并将标题放在BorderLayout.NORTH. 原来的列面板可以放在BorderLayout.CENTER.

没有必要只坚持一种布局。通常,嵌套不同的布局以获得结果更容易

于 2013-09-24T19:46:42.580 回答