// siehe aus GridBagLayout10
// Beispiel mit GridBagLayout

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

import java.awt.event.*;

import javax.swing.border.*;

public class GUI_09 extends JFrame {

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

  JLabel jLabel2 = new JLabel();
  JTextField TMatrNr = new JTextField();
  JTextField TUNummer = new JTextField();

  JLabel jLabel3 = new JLabel();
  JTextField TMatrNr2 = new JTextField("12741");
  JTextField TUNummer2 = new JTextField("U4711");

  JProgressBar jProgressBar1 = new JProgressBar();

  JButton BnUp = new JButton();
  JButton BnDown = new JButton();
  GridBagLayout gridBagLayout1 = new GridBagLayout();

  public GUI_09() {
    setSize(450, 400);
    setTitle("GridBagLayout mit Rahmen");
    setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
    setGUI();
  }

  private void setGUI() {
    this.getContentPane().setLayout(gridBagLayout1);

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

    //import javax.swing.border.*;
  	TitledBorder tb;
		tb = new TitledBorder( LineBorder.createBlackLineBorder(),
            "Eingabe");
    tb.setTitleJustification( TitledBorder.CENTER );
    tb.setTitleColor(  Color.pink );
    tb.setTitlePosition( TitledBorder.BELOW_TOP );
      //ABOVE_BOTTOM ABOVE_TOP BELOW_BOTTOM  BELOW_TOP
    tb.setTitleFont( new Font("Arial", Font.BOLD, 18)  );
		TName.setBorder(tb);

    jLabel2.setText("Nummern");
    TMatrNr.setText("12741");
		tb = new TitledBorder( LineBorder.createBlackLineBorder(),
            "Matr.-Nr");
		TMatrNr.setBorder(tb);

    TUNummer.setText("U1234");
		tb = new TitledBorder( LineBorder.createBlackLineBorder(),
            "UNummer");
		TUNummer.setBorder(tb);

    BnUp.setText("Up");
    BnUp.addActionListener(new java.awt.event.ActionListener() {

      public void actionPerformed(ActionEvent e) {
        BnUp_actionPerformed(e);
      }
    });
    BnDown.setText("Down");
    BnDown.addActionListener(new java.awt.event.ActionListener() {

      public void actionPerformed(ActionEvent e) {
        BnDown_actionPerformed(e);
      }
    });

    jProgressBar1.setMaximum(100);
    jProgressBar1.setMinimum(0);


    this.getContentPane().add(jLabel1,
            new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0
            ,GridBagConstraints.WEST,  GridBagConstraints.NONE,
            new Insets(17, 21, 0, 26), 0, 0));
    this.getContentPane().add(TName,
            new GridBagConstraints(1, 0, 2, 1, 0.0, 0.0
            ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
            new Insets(17, 25, 0, 50), 0, 0));

     // Label
    this.getContentPane().add(jLabel2,
            new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0
            ,GridBagConstraints.WEST, GridBagConstraints.NONE,
            new Insets(34, 21, 0, 0), 0, 0));
    this.getContentPane().add(TMatrNr,
            new GridBagConstraints(1, 1, 1, 1, 3.0, 0.0
            ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
            new Insets(34, 27, 0, 0), 0, 0));
    this.getContentPane().add(TUNummer,
            new GridBagConstraints(2, 1, 1, 1, 7.0, 0.0
            ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
            new Insets(34, 47, 0, 50), 0, 0));

    JPanel jpanel = new JPanel();
    jpanel.setLayout( new GridBagLayout() );
    this.getContentPane().add(jpanel,
            new GridBagConstraints(0, 2, 3, 1, 1.0, 0.0
            ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
            new Insets(33, 31, 0, 50), 0, 10));

    jpanel.add(TMatrNr2,
            new GridBagConstraints(0, 0, 1, 1, 3.0, 0.0
            ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
            new Insets(0, 0, 0, 20), 0, 0));
    jpanel.add(TUNummer2,
            new GridBagConstraints(1, 0, 1, 1, 7.0, 0.0
            ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
            new Insets(0, 0, 0, 0), 0, 0));

		tb = new TitledBorder( LineBorder.createBlackLineBorder(),
            "Nummern");
		jpanel.setBorder(tb);

            // 10 zusätzliche Höhe

    this.getContentPane().add(jProgressBar1,
            new GridBagConstraints(0, 3, 3, 1, 0.0, 0.0
            ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
            new Insets(33, 31, 0, 50), 0, 10));
            // 10 zusätzliche Höhe

    this.getContentPane().add(BnUp,
          new GridBagConstraints(0, 4, 1, 1, 0.0, 0.0
            ,GridBagConstraints.CENTER, GridBagConstraints.NONE,
            new Insets(18, 31, 5, 0), 0, 0));

    this.getContentPane().add(BnDown,
            new GridBagConstraints(2, 4, 1, 1, 0.0, 0.0
            ,GridBagConstraints.EAST, GridBagConstraints.NONE,
            new Insets(18, 47, 5, 50), 0, 10));

  } // setGUI



  void BnUp_actionPerformed(ActionEvent e) {
    jProgressBar1.setValue( jProgressBar1.getValue()+1 );
  }

  void BnDown_actionPerformed(ActionEvent e) {
    jProgressBar1.setValue( jProgressBar1.getValue()-1 );
  }

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

}
