swing
MigLayout
수색…
배치 요소
이 예제는 첫 번째 행에 두 개의 버튼이있는 총 3 개의 버튼을 배치하는 방법을 보여줍니다. 그런 다음 랩 (wrap)이 발생하므로 마지막 버튼이 새로운 행에 있습니다.
제약 조건은 단순 문자열이며,이 경우 구성 요소를 배치하는 동안 "줄 바꿈"됩니다.
public class ShowMigLayout {
// Create the elements
private final JFrame demo = new JFrame();
private final JPanel panel = new JPanel();
private final JButton button1 = new JButton("First Button");
private final JButton button2 = new JButton("Second Button");
private final JButton button3 = new JButton("Third Button");
public static void main(String[] args) {
ShowMigLayout showMigLayout = new ShowMigLayout();
SwingUtilities.invokeLater(showMigLayout::createAndShowGui);
}
public void createAndShowGui() {
// Set the position and the size of the frame
demo.setBounds(400, 400, 250, 120);
// Tell the panel to use the MigLayout as layout manager
panel.setLayout(new MigLayout());
panel.add(button1);
// Notice the wrapping
panel.add(button2, "wrap");
panel.add(button3);
demo.add(panel);
demo.setVisible(true);
}
}
산출:
Modified text is an extract of the original Stack Overflow Documentation
아래 라이선스 CC BY-SA 3.0
와 제휴하지 않음 Stack Overflow