This week's book giveaway is in the Spring forum.
We're giving away four copies of Spring in Action (5th edition) and have Craig Walls on-line!
See this thread for details.
Win a copy of Spring in Action (5th edition) this week in the Spring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Ganesh Patekar
  • Frits Walraven
  • Tim Moores
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Stephan van Hulst
  • salvin francis
  • Tim Holloway

closing a JDialog with a button  RSS feed

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
moin,

i have a problem with the following code:

i create a frame, than a dialog and with a click on the close button the dialog should be closed, so that i can work in the frame.
the control-line "hello" is displayed in the console, but the dialog doesn't disappear.

please help me...
 
Rancher
Posts: 1915
15
Android Eclipse IDE Java Java ME
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
// 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();
}
}
 
Klaus Hansen
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks a lot....
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!