我从 MIG Layout 的演示应用程序中查找了一些示例 GUI,可从他们的 Swing 网站下载 www.migcalendar.com/miglayout/swingdemoapp.jnlp
我查看了样本并喜欢它们的格式。他们还显示了源代码。他们显示源代码给出了以下输出
我用了它,这就是我得到它的方式
我使用的代码是
frame = new JFrame();
frame.setBounds(200, 100, 733, 533);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.getContentPane().setLayout(new MigLayout("ins 20","[para]0[][1001p,fill][601p][951p,fill]"));
JLabel sepLabel = new JLabel("ISD Authorization Parameters ");
frame.getContentPane().add(sepLabel);
addSeparator(frame);
JLabel label1 = new JLabel("ISD Server Hostname");
frame.getContentPane().add(label1,"skip");
final JTextField field1 = new JTextField(getSystemName());
frame.getContentPane().add(field1,"growx,span");
JLabel label2 = new JLabel("ISD Version");
frame.getContentPane().add(label2,"skip");
final JTextField field2 = new JTextField(getVersion());
frame.getContentPane().add(field2,"growx,wrap");
JLabel label3 = new JLabel("ISD Port");
frame.getContentPane().add(label3,"skip");
final JTextField field3 = new JTextField(getSystemPort());
frame.getContentPane().add(field3,"growx,wrap,span");
JLabel label4 = new JLabel("ISD UserID");
frame.getContentPane().add(label4,"skip");
final JTextField field4 = new JTextField(getUser());
frame.getContentPane().add(field4,"growx,span");
JLabel label5 = new JLabel("ISD Password");
frame.getContentPane().add(label5,"skip");
final JPasswordField field5 = new JPasswordField(getSystemPassword());
frame.getContentPane().add(field5,"growx,wrap,span,wrap para");
JLabel sepLabel1 = new JLabel("Key Store Authorization ");
frame.getContentPane().add(sepLabel1);
addSeparator(frame);
JLabel label6 = new JLabel("KeyStore Password");
frame.getContentPane().add(label6,"skip");
final JPasswordField field6 = new JPasswordField(getKeystorePassword());
frame.getContentPane().add(field6,"growx,span,wrap para");
JLabel sepLabel2 = new JLabel("Key Store Authorization ");
frame.getContentPane().add(sepLabel2);
addSeparator(frame);
JLabel label7 = new JLabel("PowerVC IP Address");
frame.getContentPane().add(label7,"skip");
final JTextField field7 = new JTextField(getHost());
frame.getContentPane().add(field7,"growx,wrap,span");
JLabel label8 = new JLabel("PowerVC User ID");
frame.getContentPane().add(label8,"skip");
final JTextField field8 = new JTextField(getUser());
frame.getContentPane().add(field8,"growx,span");
System.out.println("The value of getPassword is "+getPassword());
JLabel label9 = new JLabel("PowerVC password");
frame.getContentPane().add(label9,"skip");
final JPasswordField field9 = new JPasswordField(getPassword());
frame.getContentPane().add(field9,"growx,span,wrap para");
JButton cancelButton = new JButton("Cancel");
frame.getContentPane().add(cancelButton,"span,split,align right");
JButton updateButton = new JButton("Update");
frame.getContentPane().add(updateButton,"");
JButton updateAndExitButton = new JButton("Update and Exit");
frame.getContentPane().add(updateAndExitButton,"");
frame.setVisible(true);
private void addSeparator(JFrame frame2) {
JSeparator sep1 = new JSeparator(SwingConstants.HORIZONTAL);
sep1.setBackground(Color.CYAN);
frame2.getContentPane().add(sep1,"growx,wrap,span");
}
}
在我的 GUI 外观中比较我的 GUI 中字体的外观。在制造商之后,分离器如何启动,制造商和公司的对齐,更具体地说,我想要这种外观,我所做的看起来不太好