/**************************************************************/
/* Prof. Dr. Carsten Vogt                                     */
/* FH Koeln, Fak. 07 / Nachrichtentechnik                     */
/* http://www.nt.fh-koeln.de/vogt                             */
/*                                                            */
/* Das Programm demonstriert die Darstellung zweier Icons.    */
/**************************************************************/

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

public class Icon {

 public static void main(String args[]) {

   // Frame erzeugen:
   
   JFrame f = new JFrame("Frame mit zwei Bildern: links als JLabel, rechts als JButton");

   // Label erzeugen, das ein Bild anzeigt:
   
   JLabel lab = new JLabel(new ImageIcon("test1.jpg"));

   // Button erzeugen, das ein Bild anzeigt:

   JButton but = new JButton(new ImageIcon("test2.jpg"));
   
   but.addActionListener(
    new ActionListener() {
      public void actionPerformed(ActionEvent e) {
       JOptionPane.showMessageDialog(null,"Button gedrückt");
      }
     }
    );
   // Position und Layout des Frames setzen:

   f.setLocation(100,100);
   f.getContentPane().setLayout(new GridLayout(1,2));

   // Label und Button hinzufuegen:

   f.getContentPane().add(lab);   
   f.getContentPane().add(but);
   
   // Frame anzeigen:
   
   f.pack(); 
   f.setVisible(true);

  }

}

