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

/*
Durch die beiden Schalter wird das Label geändert.
Dabei werden auch die Schriften geändert
Jeder Schalter hat ein eigenen Action_listener
*/

public class JButton_HMTL extends JFrame {
  JToolBar toolBar = new JToolBar();
  JButton Bn1 = new JButton("1. Version");
  JButton Bn2 = new JButton("2. Version");
  JButton Bn3 = new JButton("3. Version");
  JButton Bn4 = new JButton("4. Version");
  JLabel label1;


  //Frame konstruieren
  public JButton_HMTL() {
      // Statt windowsClosing, ab JDK 1,4
    //setDefaultCloseOperation( JFrame.HIDE_ON_CLOSE );
    setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
    this.setSize(new Dimension(500, 300));
    this.setTitle("JButton_HTML");
      setGUI();
  }
    /*
     DO_NOTHING_ON_CLOSE - do not do anything - require the program to handle
                           the operation in the windowClosing method of a registered
                           WindowListener object.
     HIDE_ON_CLOSE       - automatically hide the frame after invoking any
                           registered WindowListener objects
     DISPOSE_ON_CLOSE    - automatically hide and dispose the frame after invoking
                           any registered WindowListener objects
     EXIT_ON_CLOSE
    */

  //Initialisierung der Komponente
  private void setGUI() {
    Bn1.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(ActionEvent e) {
        Bn1_Click();
      }
    });
    toolBar.add(Bn1);
    Bn1.setFont( new Font("Arial", Font.BOLD,18)  );


    Bn2.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(ActionEvent e) {
        Bn2_Click();
      }
    });
    toolBar.add(Bn2);
    Bn2.setFont( new Font("Arial", Font.BOLD,18)  );


    Bn3.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(ActionEvent e) {
        Bn3_Click();
      }
    });
    toolBar.add(Bn3);
    Bn3.setFont( new Font("Arial", Font.BOLD,18)  );

    Bn4.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(ActionEvent e) {
        Bn4_Click();
      }
    });
    toolBar.add(Bn4);
    Bn4.setFont( new Font("Arial", Font.BOLD,18)  );


    this.getContentPane().add(toolBar, BorderLayout.NORTH);

    label1 = new JLabel("<html>C=&nbsp;A<sup>2</sup>+B<sup>2</sup></html>");

//    label1.setText("<html>line 1<p><font color=blue size=+2>" + "big blue</font> line 2<p>line 3</html>");

    label1.setFont( new Font("Arial", Font.BOLD,18)  );


    this.getContentPane().add(label1, BorderLayout.CENTER);
  }  // setGUI



 void Bn1_Click() {
     label1.setText("<html><body>C=&nbsp;A<sup>2</sup>+B<sup>2</sup></body></html>");
 }


 void Bn2_Click() {
     label1.setText("<html><body>C=&nbsp;A<sub>2</sub>+B<sub>2</sub></body></html>");
  }


 void Bn3_Click() {
     label1.setText( "<html><body><table border=1 frame=hsides rules=rows>"+
        "<tr> <td>2+3*x </td>  </tr><tr> <td>2+3*x </td>  </tr> </table> </body></html>");
  }

 void Bn4_Click() {
     label1.setText(
        "<html><body><ol type=A><li>Müller, Hans</li><li>Schulze, Rolf</li><li>Meier, Andrea</li></ol></body></html>");
  }


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


}

   

