import javax.swing.JFrame;
import javax.swing.JButton;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class DialogAnwendung extends JFrame{

  public DialogAnwendung(){
    setTitle( "Dialog-Anwendung" );
    setSize( 500, 400 );
    setLayout(null);

    JButton button1 = new JButton();
    button1.setText( "Test" );
    button1.setLocation( 50, 50 );
    button1.setSize( 80, 25 );
    add( button1 );

    button1.addActionListener( new ActionListener(){
      public void actionPerformed( ActionEvent e ){
        onButton1Click();
      }
    });
    
  }

  private void onButton1Click(){
    System.out.println( "button1 wurde angeklickt" );
  }

  public static void main(String[] args ){
    DialogAnwendung dlg = new DialogAnwendung();
    dlg.setVisible(true);
  }

}