swing
MigLayout
खोज…
लपेटने वाले तत्व
यह उदाहरण दर्शाता है कि पहली पंक्ति में 2 बटन होने के साथ कुल 3 बटन कैसे रखें। फिर एक रैप होता है, इसलिए अंतिम बटन एक नई पंक्ति में होता है।
बाधाएं सरल तार हैं, इस मामले में घटक को रखते समय "लपेटें"।
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