如何使用Java Swing布局管理器来制作这个GUI?

布局

我试图弄清楚应该在JFrame上使用哪些布局来完成这种布局。 我正在尝试编写GUI而不是使用可视化GUI制作工具。 到目前为止,我只能让它看起来像这样: 在此处输入图像描述

这是上面GUI的源代码: http : //pastebin.com/s06pareG

/** * Initialize the contents of the frame. */ private void initialize() { frame = new JFrame(); frame.setBounds(100, 100, 450, 300); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //frame.getContentPane().setLayout(new FlowLayout(FlowLayout.CENTER, 5, 5)); JPanel upPanel = new JPanel(); upPanel.setLayout(new GridLayout(2,3)); JLabel data = new JLabel("Data Source Name:"); upPanel.add(data); JTextField dataText = new JTextField(); upPanel.add(dataText); JLabel desc = new JLabel("Description:"); upPanel.add(desc); JTextField descText = new JTextField(); upPanel.add(descText); JPanel midPanel = new JPanel(); midPanel.setBorder(new TitledBorder(null, "Database", TitledBorder.LEADING, TitledBorder.TOP, null, null)); JLabel dbTitle = new JLabel("Database"); JButton select = new JButton("Select..."); JButton create = new JButton("Create..."); JButton repair = new JButton("Repair..."); JButton compact = new JButton("Compact..."); JPanel eastPanel = new JPanel(); eastPanel.setLayout(new GridLayout(4,1)); JButton ok = new JButton("OK"); JButton cancel = new JButton("Cancel"); JButton help = new JButton("Help"); JButton advanced = new JButton("Advanced..."); eastPanel.add(ok); eastPanel.add(cancel); eastPanel.add(help); eastPanel.add(advanced); frame.getContentPane().add(upPanel, BorderLayout.NORTH); frame.getContentPane().add(midPanel, BorderLayout.WEST); midPanel.setLayout(new BorderLayout(0, 0)); midPanel.add(dbTitle); midPanel.add(select); midPanel.add(create); midPanel.add(repair); midPanel.add(compact); frame.getContentPane().add(eastPanel, BorderLayout.EAST); } 

我正在考虑制作JFrame绝对布局,然后使用GridLayout创建4个JPanel。 另外,我无法将“Database:”标签放在自己的行上并将JButton放在它下面。 我应该考虑哪些类型的布局和自定义function来实现这种外观?

将布局分解为基本的责任区域,单独关注每个区域并管理自己的布局要求

所以,正如我所见,你有四个基本function领域……

部分

您需要将它们分解为各自的组件,并专注于布局和function要求

第01部分

Part01

所以,这是非常基本的

 public class SourcePane extends JPanel { private JTextField datasourceName; private JTextField desciption; public SourcePane() { setLayout(new GridBagLayout()); GridBagConstraints gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 0; gbc.anchor = GridBagConstraints.WEST; add(new JLabel("Data Source Name: "), gbc); gbc.gridy++; add(new JLabel("Description: "), gbc); gbc.gridx++; gbc.gridy = 0; gbc.weightx = 1; gbc.fill = GridBagConstraints.HORIZONTAL; add((datasourceName = new JTextField(10)), gbc); gbc.gridy++; add((desciption = new JTextField(10)), gbc); } public String getDataSourceName() { return datasourceName.getText(); } public String getDescription() { return desciption.getText(); } public void setDataSourceName(String name) { datasourceName.setText(name); } public void setDescription(String description) { desciption.setText(description); } } 

我还添加了一些访问器,我将不会添加到其余的代码中,但提供了如何在组件之间获取/设置信息的想法

第02部分

Part02

这比较困难,因为在Database:标签旁边有一个附加标签的建议。 “可能”可以在单一布局中完成此操作,但使用其他容器并进一步复合布局会更容易

 public class DatabasePane extends JPanel { private JButton select, create, repair, compact; private JLabel database; public DatabasePane() { setLayout(new GridBagLayout()); setBorder(new CompoundBorder(new TitledBorder("Database"), new EmptyBorder(12, 0, 0, 0))); GridBagConstraints gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 0; gbc.anchor = GridBagConstraints.WEST; gbc.insets = new Insets(0, 0, 0, 4); JPanel panel = new JPanel(new GridBagLayout()); panel.add(new JLabel("Database: "), gbc); gbc.gridx++; gbc.weightx = 1; gbc.fill = GridBagConstraints.HORIZONTAL; gbc.insets = new Insets(0, 0, 0, 0); panel.add((database = new JLabel()), gbc); gbc.gridx = 0; gbc.gridy = 0; gbc.weightx = 1; gbc.gridwidth = GridBagConstraints.REMAINDER; gbc.fill = GridBagConstraints.HORIZONTAL; gbc.insets = new Insets(4, 4, 4, 4); add(panel, gbc); gbc.gridwidth = 1; gbc.weightx = 0.25; gbc.gridy++; gbc.fill = GridBagConstraints.HORIZONTAL; add((select = new JButton("Select")), gbc); gbc.gridx++; add((create = new JButton("Create")), gbc); gbc.gridx++; add((repair = new JButton("Repair")), gbc); gbc.gridx++; add((compact = new JButton("Compact")), gbc); } } 

第03部分

第03部分

再次,这看起来有点复杂,因为Database:按钮似乎有一个额外的标签。 您可以简单地使用按钮text属性,但我选择进一步演示复合布局的想法

 public class SystemDatabasePane extends JPanel { private JRadioButton none, database; private JLabel databaseLabel; private JButton systemDatabase; public SystemDatabasePane() { setLayout(new GridBagLayout()); setBorder(new CompoundBorder(new TitledBorder("System Database"), new EmptyBorder(8, 0, 0, 0))); GridBagConstraints gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 0; gbc.insets = new Insets(0, 0, 0, 4); gbc.anchor = GridBagConstraints.WEST; JPanel panel = new JPanel(new GridBagLayout()); panel.add((none = new JRadioButton("None")), gbc); gbc.gridy++; panel.add((none = new JRadioButton("Database: ")), gbc); gbc.gridx++; gbc.weightx = 1; gbc.fill = GridBagConstraints.HORIZONTAL; panel.add((databaseLabel = new JLabel("")), gbc); gbc.gridx = 0; gbc.gridy = 0; gbc.weightx = 1; gbc.gridwidth = GridBagConstraints.REMAINDER; gbc.fill = GridBagConstraints.HORIZONTAL; gbc.insets = new Insets(4, 4, 4, 4); add(panel, gbc); gbc.gridy++; gbc.fill = GridBagConstraints.NONE; gbc.anchor = GridBagConstraints.CENTER; add((systemDatabase = new JButton("System Database...")), gbc); systemDatabase.setEnabled(false); } } 

第04部分

第04部分

最后,“行动”小组。 这实际上相对简单,但是利用GridBagLayout及其约束的属性来在单个布局中完成整个事情

 public class ActionPane extends JPanel { private JButton okay, cancel, help, advanced, options; public ActionPane() { setLayout(new GridBagLayout()); GridBagConstraints gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 0; gbc.gridwidth = GridBagConstraints.REMAINDER; gbc.fill = GridBagConstraints.HORIZONTAL; gbc.weightx = 1; gbc.insets = new Insets(4, 4, 4, 4); add((okay = new JButton("Ok")), gbc); gbc.gridy++; add((cancel = new JButton("Cancel")), gbc); gbc.gridy++; add((help = new JButton("Help")), gbc); gbc.gridy++; add((advanced = new JButton("Advanced")), gbc); gbc.gridy++; gbc.weighty = 1; gbc.anchor = GridBagConstraints.SOUTH; add((options = new JButton("Options >>")), gbc); } } 

把它们放在一起

最后

然后,这将所有单独的元素组合在一起成为一个布局

 public class DatabasePropertiesPane extends JPanel { private SourcePane sourcePane; private DatabasePane databasePane; private SystemDatabasePane systemDatabasePane; private ActionPane actionPane; public DatabasePropertiesPane() { setLayout(new GridBagLayout()); GridBagConstraints gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 0; gbc.weightx = 1; gbc.weighty = 0.33; gbc.anchor = GridBagConstraints.WEST; gbc.fill = GridBagConstraints.BOTH; gbc.insets = new Insets(4, 4, 4, 4); add((sourcePane = new SourcePane()), gbc); gbc.gridy++; add((databasePane = new DatabasePane()), gbc); gbc.gridy++; add((systemDatabasePane = new SystemDatabasePane()), gbc); gbc.gridy = 0; gbc.gridx++; gbc.gridheight = GridBagConstraints.REMAINDER; gbc.fill = GridBagConstraints.VERTICAL; gbc.weighty = 1; gbc.weightx = 0; add((actionPane = new ActionPane()), gbc); } } 

可运行的例子

 import java.awt.Color; import java.awt.EventQueue; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; import java.awt.Insets; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JRadioButton; import javax.swing.JTextField; import javax.swing.UIManager; import javax.swing.UnsupportedLookAndFeelException; import javax.swing.border.CompoundBorder; import javax.swing.border.EmptyBorder; import javax.swing.border.LineBorder; import javax.swing.border.TitledBorder; public class TestLayout { public static void main(String[] args) { new TestLayout(); } public TestLayout() { EventQueue.invokeLater(new Runnable() { @Override public void run() { try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException ex) { ex.printStackTrace(); } JFrame frame = new JFrame("Testing"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.add(new DatabasePropertiesPane()); frame.pack(); frame.setLocationRelativeTo(null); frame.setVisible(true); } }); } public class DatabasePropertiesPane extends JPanel { private SourcePane sourcePane; private DatabasePane databasePane; private SystemDatabasePane systemDatabasePane; private ActionPane actionPane; public DatabasePropertiesPane() { setLayout(new GridBagLayout()); GridBagConstraints gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 0; gbc.weightx = 1; gbc.weighty = 0.33; gbc.anchor = GridBagConstraints.WEST; gbc.fill = GridBagConstraints.BOTH; gbc.insets = new Insets(4, 4, 4, 4); add((sourcePane = new SourcePane()), gbc); gbc.gridy++; add((databasePane = new DatabasePane()), gbc); gbc.gridy++; add((systemDatabasePane = new SystemDatabasePane()), gbc); gbc.gridy = 0; gbc.gridx++; gbc.gridheight = GridBagConstraints.REMAINDER; gbc.fill = GridBagConstraints.VERTICAL; gbc.weighty = 1; gbc.weightx = 0; add((actionPane = new ActionPane()), gbc); } } public class SourcePane extends JPanel { private JTextField datasourceName; private JTextField desciption; public SourcePane() { setLayout(new GridBagLayout()); GridBagConstraints gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 0; gbc.anchor = GridBagConstraints.WEST; add(new JLabel("Data Source Name: "), gbc); gbc.gridy++; add(new JLabel("Description: "), gbc); gbc.gridx++; gbc.gridy = 0; gbc.weightx = 1; gbc.fill = GridBagConstraints.HORIZONTAL; add((datasourceName = new JTextField(10)), gbc); gbc.gridy++; add((desciption = new JTextField(10)), gbc); } public String getDataSourceName() { return datasourceName.getText(); } public String getDescription() { return desciption.getText(); } public void setDataSourceName(String name) { datasourceName.setText(name); } public void setDescription(String description) { desciption.setText(description); } } public class DatabasePane extends JPanel { private JButton select, create, repair, compact; private JLabel database; public DatabasePane() { setLayout(new GridBagLayout()); setBorder(new CompoundBorder(new TitledBorder("Database"), new EmptyBorder(12, 0, 0, 0))); GridBagConstraints gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 0; gbc.anchor = GridBagConstraints.WEST; gbc.insets = new Insets(0, 0, 0, 4); JPanel panel = new JPanel(new GridBagLayout()); panel.add(new JLabel("Database: "), gbc); gbc.gridx++; gbc.weightx = 1; gbc.fill = GridBagConstraints.HORIZONTAL; gbc.insets = new Insets(0, 0, 0, 0); panel.add((database = new JLabel()), gbc); gbc.gridx = 0; gbc.gridy = 0; gbc.weightx = 1; gbc.gridwidth = GridBagConstraints.REMAINDER; gbc.fill = GridBagConstraints.HORIZONTAL; gbc.insets = new Insets(4, 4, 4, 4); add(panel, gbc); gbc.gridwidth = 1; gbc.weightx = 0.25; gbc.gridy++; gbc.fill = GridBagConstraints.HORIZONTAL; add((select = new JButton("Select")), gbc); gbc.gridx++; add((create = new JButton("Create")), gbc); gbc.gridx++; add((repair = new JButton("Repair")), gbc); gbc.gridx++; add((compact = new JButton("Compact")), gbc); } } public class SystemDatabasePane extends JPanel { private JRadioButton none, database; private JLabel databaseLabel; private JButton systemDatabase; public SystemDatabasePane() { setLayout(new GridBagLayout()); setBorder(new CompoundBorder(new TitledBorder("System Database"), new EmptyBorder(8, 0, 0, 0))); GridBagConstraints gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 0; gbc.insets = new Insets(0, 0, 0, 4); gbc.anchor = GridBagConstraints.WEST; JPanel panel = new JPanel(new GridBagLayout()); panel.add((none = new JRadioButton("None")), gbc); gbc.gridy++; panel.add((none = new JRadioButton("Database: ")), gbc); gbc.gridx++; gbc.weightx = 1; gbc.fill = GridBagConstraints.HORIZONTAL; panel.add((databaseLabel = new JLabel("")), gbc); gbc.gridx = 0; gbc.gridy = 0; gbc.weightx = 1; gbc.gridwidth = GridBagConstraints.REMAINDER; gbc.fill = GridBagConstraints.HORIZONTAL; gbc.insets = new Insets(4, 4, 4, 4); add(panel, gbc); gbc.gridy++; gbc.fill = GridBagConstraints.NONE; gbc.anchor = GridBagConstraints.CENTER; add((systemDatabase = new JButton("System Database...")), gbc); systemDatabase.setEnabled(false); } } public class ActionPane extends JPanel { private JButton okay, cancel, help, advanced, options; public ActionPane() { setLayout(new GridBagLayout()); GridBagConstraints gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 0; gbc.gridwidth = GridBagConstraints.REMAINDER; gbc.fill = GridBagConstraints.HORIZONTAL; gbc.weightx = 1; gbc.insets = new Insets(4, 4, 4, 4); add((okay = new JButton("Ok")), gbc); gbc.gridy++; add((cancel = new JButton("Cancel")), gbc); gbc.gridy++; add((help = new JButton("Help")), gbc); gbc.gridy++; add((advanced = new JButton("Advanced")), gbc); gbc.gridy++; gbc.weighty = 1; gbc.anchor = GridBagConstraints.SOUTH; add((options = new JButton("Options >>")), gbc); } } } 

查看在容器中布置组件以及如何使用GridBagLayout获取更多详细信息

不幸的是,它对这些部分的说法不好,但Netbeans的GUI Builder非常适合这种项目。 这张图片中的GUI花了我大约五分钟的时间来构建:

在此处输入图像描述

我实际上录制了一段video,但video效果并不理想,因为我太便宜而无法支付好的屏幕录制软件。 无论如何,我推荐Netbeans GUI Builder。 学习曲线根本不陡(特别是与手写布局管理器相比),它可以做任何其他布局管理器可以做的任何事情,并且更快。

下面是生成的代码, 但我强烈建议您自己动手,因为Netbeans还会生成一个对GUI Builder正常运行至关重要的.xml文件。 如果你想在未来做出改变,你需要GUI Builder这样做(其中一个缺点,但对我来说这是次要的)。

 public class NewJPanel2 extends javax.swing.JPanel { /** * Creates new form NewJPanel2 */ public NewJPanel2() { initComponents(); } /** * This method is called from within the constructor to initialize the form. * WARNING: Do NOT modify this code. The content of this method is always * regenerated by the Form Editor. */ @SuppressWarnings("unchecked") //  private void initComponents() { jLabel1 = new javax.swing.JLabel(); jLabel2 = new javax.swing.JLabel(); jTextField1 = new javax.swing.JTextField(); jTextField2 = new javax.swing.JTextField(); jButton1 = new javax.swing.JButton(); jButton4 = new javax.swing.JButton(); jButton2 = new javax.swing.JButton(); jButton3 = new javax.swing.JButton(); jPanel1 = new javax.swing.JPanel(); jLabel3 = new javax.swing.JLabel(); jButton5 = new javax.swing.JButton(); jButton6 = new javax.swing.JButton(); jButton7 = new javax.swing.JButton(); jButton8 = new javax.swing.JButton(); jPanel2 = new javax.swing.JPanel(); jRadioButton1 = new javax.swing.JRadioButton(); jRadioButton2 = new javax.swing.JRadioButton(); jButton9 = new javax.swing.JButton(); jButton10 = new javax.swing.JButton(); jLabel1.setText("Data Source Name:"); jLabel2.setText("Description:"); jButton1.setText("Ok"); jButton4.setText("Cancel"); jButton2.setText("Help"); jButton3.setText("Advanced"); jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("Database")); jLabel3.setText("Database:"); jButton5.setText("Select"); jButton6.setText("Create"); jButton7.setText("Compact"); jButton8.setText("Repair"); javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); jPanel1.setLayout(jPanel1Layout); jPanel1Layout.setHorizontalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() .addContainerGap() .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel3) .addGroup(jPanel1Layout.createSequentialGroup() .addComponent(jButton5) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(jButton6, javax.swing.GroupLayout.PREFERRED_SIZE, 65, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(jButton8, javax.swing.GroupLayout.PREFERRED_SIZE, 63, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(jButton7, javax.swing.GroupLayout.PREFERRED_SIZE, 75, javax.swing.GroupLayout.PREFERRED_SIZE))) .addContainerGap()) ); jPanel1Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jButton5, jButton6, jButton7, jButton8}); jPanel1Layout.setVerticalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() .addGap(24, 24, 24) .addComponent(jLabel3) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jButton5) .addComponent(jButton6) .addComponent(jButton8) .addComponent(jButton7)) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) ); jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder("System Database")); jRadioButton1.setText("None"); jRadioButton2.setText("Database:"); jButton9.setText("System Database..."); jButton9.setEnabled(false); javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2); jPanel2.setLayout(jPanel2Layout); jPanel2Layout.setHorizontalGroup( jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel2Layout.createSequentialGroup() .addContainerGap() .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jRadioButton1) .addGroup(jPanel2Layout.createSequentialGroup() .addComponent(jRadioButton2) .addGap(49, 49, 49) .addComponent(jButton9))) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) ); jPanel2Layout.setVerticalGroup( jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel2Layout.createSequentialGroup() .addGap(15, 15, 15) .addComponent(jRadioButton1) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jRadioButton2) .addContainerGap(29, Short.MAX_VALUE)) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup() .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jButton9) .addContainerGap()) ); jButton10.setText("Options>>"); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); this.setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addContainerGap() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false) .addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jTextField1) .addComponent(jTextField2)) .addGap(18, 18, 18) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jButton1, javax.swing.GroupLayout.Alignment.TRAILING) .addComponent(jButton4, javax.swing.GroupLayout.Alignment.TRAILING))) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addComponent(jPanel2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jButton2, javax.swing.GroupLayout.Alignment.TRAILING) .addComponent(jButton3, javax.swing.GroupLayout.Alignment.TRAILING)) .addComponent(jButton10, javax.swing.GroupLayout.Alignment.TRAILING)))) .addContainerGap()) ); layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jButton1, jButton10, jButton2, jButton3, jButton4}); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addContainerGap() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel1) .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jButton1)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel2) .addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jButton4)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addComponent(jButton2) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jButton3)) .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGroup(layout.createSequentialGroup() .addGap(0, 0, Short.MAX_VALUE) .addComponent(jButton10))) .addContainerGap()) ); }//  // Variables declaration - do not modify private javax.swing.JButton jButton1; private javax.swing.JButton jButton10; private javax.swing.JButton jButton2; private javax.swing.JButton jButton3; private javax.swing.JButton jButton4; private javax.swing.JButton jButton5; private javax.swing.JButton jButton6; private javax.swing.JButton jButton7; private javax.swing.JButton jButton8; private javax.swing.JButton jButton9; private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel2; private javax.swing.JLabel jLabel3; private javax.swing.JPanel jPanel1; private javax.swing.JPanel jPanel2; private javax.swing.JRadioButton jRadioButton1; private javax.swing.JRadioButton jRadioButton2; private javax.swing.JTextField jTextField1; private javax.swing.JTextField jTextField2; // End of variables declaration }