
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
//import java.io.*;

// Drei Schalter sind in SOUTH eingetragen
// aber in einem JPanel, mit FlowLayout
public class BorderLayout2 extends JFrame {


  //Frame konstruieren
  public BorderLayout2() {
     JButton bn1a, bn2a, bn3;

    setSize(400, 300);
    setTitle("BorderLayout2");

    this.getContentPane().setLayout ( new BorderLayout(10,20) );  // vgap, hgap


    JPanel panelBn = new JPanel();
    //Container panelBn = new Container();

    // optionale Ausrichtung im FlowLayout
    // FlowLayout.LEFT, FlowLayout.CENTER (default), FlowLayout.RIGHT
    FlowLayout myLayout =  new FlowLayout(FlowLayout.CENTER);
    //FlowLayout myLayout = new FlowLayout();

    panelBn.setLayout ( myLayout );  // Schalter in der Mitte
    JToggleButton bn1 = new JToggleButton("1. Text");  // Label erzeugen
    panelBn.add(bn1);
    JToggleButton bn2 = new JToggleButton("2. Text");  // Label erzeugen
    panelBn.add(bn2);
    bn3 = new JButton("3. Text");  // Label erzeugen
    panelBn.add(bn3);

    panelBn.setBackground(   Color.green );
    bn1.setFont( new Font("Arial", Font.BOLD,18)  );
    bn2.setFont( new Font("Arial", Font.BOLD,18)  );
    bn3.setFont( new Font("Arial", Font.BOLD,18)  );

    this.getContentPane().add(panelBn, BorderLayout.SOUTH);
  } // create



  //Überschreiben, damit das Programm bei Herunterfahren des Systems beendet werden kann
  protected void processWindowEvent(WindowEvent e) {
    super.processWindowEvent(e);
    if(e.getID() == WindowEvent.WINDOW_CLOSING) {
      System.exit(0);
    }
  }


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


}
