MigLayout

import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import net.miginfocom.swing.MigLayout;

public class Test {
    public static void main(String[] args) {
        JLabel firstNameLabel = new JLabel("First Name");
        JLabel lastNameLabel = new JLabel("Last Name");
        JLabel addressLabel = new JLabel("Address");
        JTextField firstNameTextField = new JTextField(20);
        JTextField lastNameTextField = new JTextField(20);
        JTextField addressTextField = new JTextField();
        JPanel panel = new JPanel(new MigLayout());

        panel.add(firstNameLabel);
        panel.add(firstNameTextField);
        panel.add(lastNameLabel, "gap unrelated");
        panel.add(lastNameTextField, "wrap");
        panel.add(addressLabel);
        panel.add(addressTextField, "span, grow");

        JFrame jframe = new JFrame();
        jframe.add(panel);
        jframe.setSize(300, 100);
        jframe.setVisible(true);
        jframe.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    }
}

 详见:http://www.miglayout.com/ 并有quick guide,所需jar包以上传于附件

 

 

你可能感兴趣的:(.net,swing)