Frage

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.

War es hilfreich?

Lösung

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.

Wrap a JPanel around each of your columns with a BorderLayout and put the header in the BorderLayout.NORTH. The original column panel can be put in the BorderLayout.CENTER.

There is no need to stick to just one layout. Typically it is easier to nest different layouts to obtain a result

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top