
//Titel:			Layoutbeispiel
//Version:
//Copyright:		Copyright (c) 1999, 2010
//Autor:			Ihr Name
//Organisation:	HS-Harz
//Beschreibung:	Test mit Layout

// GridbagLayout02.java	Editoreingabe mit GridbagLayout
// 2 Editorzeilen mit horizontaler Ausrichtung

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

import java.awt.event.*;


public class GridBagLayout02 extends JFrame {

  JLabel jLabel1 = new JLabel();
  JTextField TName = new JTextField();
  JLabel jLabel2 = new JLabel();
  JTextField TName2 = new JTextField();

  JButton BnOk = new JButton();
  JButton BnESC = new JButton();

  public GridBagLayout02() {
    setSize(400, 230);
    setTitle("GridBagLayout02. Beispiel");
    setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
    setGUI();
  }

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

    jLabel1.setText("A");
    TName.setText("-");

    jLabel2.setText("ABCDEFGHIJKL");
    TName2.setText("-");

    jLabel1.setFont( new Font("Arial", Font.BOLD,18)  );
    TName.setFont( new Font("Arial", Font.BOLD,18)  );
    jLabel2.setFont( new Font("Arial", Font.BOLD,18)  );
    TName2.setFont( new Font("Arial", Font.BOLD,18)  );

    BnOk.setText("Ok");
    BnESC.setText("Abbruch");
    BnOk.setFont( new Font("Arial", Font.BOLD,18)  );
    BnESC.setFont( new Font("Arial", Font.BOLD,18)  );

    int w=BnESC.getWidth();
    int h=BnESC.getHeight();
    BnOk.setPreferredSize( BnESC.getPreferredSize() );

    this.getContentPane().add(jLabel1,
         new GridBagConstraints(
             0, 0, 1, 1, 20.0, 0.0
            ,GridBagConstraints.WEST,
            GridBagConstraints.HORIZONTAL,
            new Insets(10,25,40,0), 0, 0));

    this.getContentPane().add(TName,
        new GridBagConstraints(
               1, 0, 1, 1, 80.0, 0.0
            ,GridBagConstraints.WEST,
            GridBagConstraints.HORIZONTAL,
            new Insets(10,25,40,25), 0, 0));


    this.getContentPane().add(jLabel2,
         new GridBagConstraints(
             0, 1, 1, 1, 20.0, 0.0
            ,GridBagConstraints.WEST,
            GridBagConstraints.HORIZONTAL,
            new Insets(0,25,40,0), 0, 0));

    this.getContentPane().add(TName2,
        new GridBagConstraints(
             1, 1, 1, 1, 80.0, 0.0
            ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
            new Insets(0,25,40,25), 0, 0));



    JPanel pn = new JPanel();
    pn.add(BnOk);
    pn.add(BnESC);
//    pn.setBackground(Color.green);
    this.getContentPane().add(pn,
           new GridBagConstraints(0, 2, 2, 1, 1.0, 0.0
            ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
            new Insets(0,0,0,0), 0, 0));

  }  // setGUI




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

}

