2 * This file is part of lanterna (http://code.google.com/p/lanterna/).
4 * lanterna is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 * Copyright (C) 2010-2015 Martin
19 package com
.googlecode
.lanterna
.gui2
;
22 * Utility class for quickly bunching up components in a panel, arranged in a particular pattern
28 * Creates a new {@code Panel} with a {@code LinearLayout} layout manager in horizontal mode and adds all the
29 * components passed in
30 * @param components Components to be added to the new {@code Panel}, in order
31 * @return The new {@code Panel}
33 public static Panel
horizontal(Component
... components
) {
34 Panel panel
= new Panel();
35 panel
.setLayoutManager(new LinearLayout(Direction
.HORIZONTAL
));
36 for(Component component
: components
) {
37 panel
.addComponent(component
);
43 * Creates a new {@code Panel} with a {@code LinearLayout} layout manager in vertical mode and adds all the
44 * components passed in
45 * @param components Components to be added to the new {@code Panel}, in order
46 * @return The new {@code Panel}
48 public static Panel
vertical(Component
... components
) {
49 Panel panel
= new Panel();
50 panel
.setLayoutManager(new LinearLayout(Direction
.VERTICAL
));
51 for(Component component
: components
) {
52 panel
.addComponent(component
);
58 * Creates a new {@code Panel} with a {@code GridLayout} layout manager and adds all the components passed in
59 * @param columns Number of columns in the grid
60 * @param components Components to be added to the new {@code Panel}, in order
61 * @return The new {@code Panel}
63 public static Panel
grid(int columns
, Component
... components
) {
64 Panel panel
= new Panel();
65 panel
.setLayoutManager(new GridLayout(columns
));
66 for(Component component
: components
) {
67 panel
.addComponent(component
);