import java.awt.*;
import javax.swing.*;


// GridBagLayout für eine Editorzeile


public class GridBagLayout02a extends JFrame {

  JLabel label1 = new JLabel();
  JLabel label2 = new JLabel();
  JTextField text1 = new JTextField();
  JTextField text2 = new JTextField();

  JButton BnOk = new JButton("Ok");
  JButton BnEsc = new JButton("Abbruch");

  JPanel panel1 = new JPanel();

  public GridBagLayout02a() {
    setSize(400, 200);
    setTitle("GridBagLayout01. Beispiel, FlowPanel");
    setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
    setGUI();
  }

  private void setGUI() {
    this.getContentPane().setLayout( 
         new GridBagLayout() );

    label1.setText("XE");
    label2.setText("Eingaben");
    text1.setText("a");
    text2.setText("b");

    //BnOk.setPreferredSize(  BnEsc.getPreferredSize() );

   BnOk.setFont( new Font("Arial", Font.BOLD,18)  );
   BnEsc.setFont( new Font("Arial", Font.BOLD,18)  );
   label1.setFont( new Font("Arial", Font.BOLD,18)  );
   text1.setFont( new Font("Arial", Font.BOLD,18)  );
   label2.setFont( new Font("Arial", Font.BOLD,18)  );
   text2.setFont( new Font("Arial", Font.BOLD,18)  );

    this.getContentPane().add(label1,
       new GridBagConstraints(
           0, 0, 1, 1, 0.0, 0.0
      ,GridBagConstraints.WEST,
      GridBagConstraints.NONE,
         new Insets(0,30,0,20), 0, 0));

    add(text1,
       new GridBagConstraints(
           1, 0, 1, 1, 100.0, 0.0
      ,GridBagConstraints.WEST,
      GridBagConstraints.HORIZONTAL,
         new Insets(0,0,0,30), 0, 0));

    this.getContentPane().add(label2,
       new GridBagConstraints(
           0, 1, 1, 1, 0.0, 0.0
      ,GridBagConstraints.WEST,
      GridBagConstraints.NONE,
         new Insets(20,30,0,20), 0, 0));

    add(text2,
       new GridBagConstraints(
           1, 1, 1, 1, 100.0, 0.0
      ,GridBagConstraints.WEST,
      GridBagConstraints.HORIZONTAL,
         new Insets(20,0,0,30), 0, 0));



    panel1.setLayout( new FlowLayout() );
    panel1.add(BnOk);
    panel1.add(BnEsc);
    panel1.setBackground(Color.red);

    this.getContentPane().add(panel1,
       new GridBagConstraints(
          0,2, 2, 1, 100.0, 0.0
      ,GridBagConstraints.CENTER,
      GridBagConstraints.HORIZONTAL,
         new Insets(20,0,20,0), 0, 0));  // Top left Bottom Right
  
    }


  public static void main(String[] args) {
    GridBagLayout02a frame = 
        new GridBagLayout02a();
    frame.setVisible(true);
 }

}

