Как мне оставить Align Labels в JPanel?JAVA

Программисты JAVA общаются здесь
Anonymous
Как мне оставить Align Labels в JPanel?

Сообщение Anonymous »

Я не могу получить метки, чтобы добраться до Boxlayout. Всегда есть какое -то пустое пространство, независимо от того, что я делаю.
Я хочу каждый элемент в отдельной строке. Combobox растянулся, маркировки влево выровнены. Как я могу это сделать?

Код: Выделить всё

public static void addComponentsToPane(Container pane) {
JPanel configPanel = new JPanel();
configPanel.setLayout(new BoxLayout(configPanel, BoxLayout.Y_AXIS));

JLabel configLabel = new JLabel("Server Configuration:", SwingConstants.LEFT);
configPanel.add(configLabel);

JComboBox profileComboBox = new JComboBox();
configPanel.add(profileComboBox);

JLabel schemaLabel = new JLabel("Database Schema:", SwingConstants.LEFT);
configPanel.add(schemaLabel);

JComboBox schemaComboBox = new JComboBox();
configPanel.add(schemaComboBox);

pane.add(configPanel, BorderLayout.NORTH);
}


Подробнее здесь: https://stackoverflow.com/questions/797 ... -in-jpanel

Вернуться в «JAVA»