// Should work now, look at the commented line below
you should get the idea, a new JDailog object was getting created.
package testen;
import java.awt.event.*;
import javax.swing.*;
public class ProbDialogClose {
static JFrame f = new JFrame("test");
static JDialog dialog = new JDialog( f, true );
ProbDialogClose()
{
f.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
f.setVisible( true );
showWelcomeMessage();
}
private void showWelcomeMessage(){
//JDialog dialog = new JDialog( f, true );
dialog.setSize( 450, 400 );
dialog.setLayout(null);
JButton closeButton = new JButton("Fenster schließen");
closeButton.setSize(150, 30);
closeButton.addActionListener( new ActionListener() {
public void actionPerformed( ActionEvent e ) {
closeWelcomeMessage();
}
} );
dialog.add( closeButton );
dialog.setVisible( true );
}
private void closeWelcomeMessage(){
System.out.println("hello");
dialog.setVisible(false);
dialog.dispose();
}
public static void main(
String[] args ) {
new ProbDialogClose();
}
}