aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes closing a JDialog Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "closing a JDialog" Watch "closing a JDialog" New topic
Author

closing a JDialog

Hasnain S
Greenhorn

Joined: Jul 18, 2006
Posts: 17
i have search here but non have my problem....ahem

in my custom dialog that opens up when u click ok or cancel it simply goes
addCust.dialog.setVisible(false);

this way the window disappears by in my taskbar i can still see that java session alive

how do i kill it

i tried
dialog.setVisible(false);
dialog.dispose();

and then
dialog.dispose();

but it doesnt work

i want that session KILLED!!!
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 13884
    
  10

Try:


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
Hasnain S
Greenhorn

Joined: Jul 18, 2006
Posts: 17
i already did....it killed the whole [program

i just want the dialog to die....it disappears but stays in the taskbar
[ July 22, 2006: Message edited by: Hasnain SS ]
Hasnain S
Greenhorn

Joined: Jul 18, 2006
Posts: 17
well i still havent solved the problem so if anyone can help...please do so...


bump
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
what shows in the taskbar is the dialog's parent, not the dialog.

can you post a simple demo program, so we can see exactly how you are doing this
Hasnain S
Greenhorn

Joined: Jul 18, 2006
Posts: 17
i could send it coz the program code is too big to post here

i am pretty sure that the ghost is of the Jdialog

pm me if possible
Hasnain S
Greenhorn

Joined: Jul 18, 2006
Posts: 17
i have sent at ur email

plz chek it
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
the part creating the extra taskbar item is caused by the code in addCust
going around in circles i.e. you seem to be creating a separate dialog/frame
within the dialog itself, instead of using the class as a dialog (extends JDialog)

a couple of changes in mainFrame
1) starting at line 587

2) added a 'main' to mainFrame


and this is the modified addCust code
Hasnain S
Greenhorn

Joined: Jul 18, 2006
Posts: 17
ok it didnt work

plz bear with me...im going to list the changes...

No.1=================================

//selectedNames = addCust.showDialog(centerPanel);//<-------cancelled

addCust ac = new addCust(mainFrame.this);//<----------added

//selectedNames = addCust.showDialog(mainFrame.this); //<---this wasnt there when i put it it give me error
selectedNames = ac.showDialog();//<-----i added this

No.2==================================

why did u add a main to the mainFrame? I already had one in dFreeze.java

thats how i learnt it......to keep main away from the code....

anyway i added it in the end just before the last }...and surprisngly it compiled and ran normally

No.3==================================
//public static ArrayList showDialog(Component frameComp)
//public static ArrayList showDialog(JFrame frameComp)
public static ArrayList showDialog()//

i did not understand this part so i removed the first line, the second wasnt there anyway, and added the last one.....

then changed from private to public and in the same line from Frame to JFrame

removed pack(); and added the three lines....

replaced addCust.dialog.setVisible(false) with dispose();

----------------------------------------------------------------
****************************************************************
-----------------------------------------------------------------

i believe thats it....if i missed out something please correct me....or if the code you edited works fine on ur comp then just send the edited files back.....thx for helping me out
[ July 24, 2006: Message edited by: Hasnain SS ]
Hasnain S
Greenhorn

Joined: Jul 18, 2006
Posts: 17
can u also tell me why is it that when i load a csv file i get 3 new ghost windows opened?

edit : and here is a pic of the above problem

http://img153.imageshack.us/img153/7374/untitledyj8.png
[ July 24, 2006: Message edited by: Hasnain SS ]
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
left out one other change in mainFrame, line 102
//this.setVisible(true);//comment out

thought I had checked the 8 files for main(), but missed it in dFreeze.java
that's the only reason I added it. can now be removed from mainFrame.java

the other 2 code changes are just straight swaps
1) listener class
2) addCust.java

the extra change above stops all the taskbar entries, but there's too much
code for me to wade through to see if it's a fix, or just a mask.
Hasnain S
Greenhorn

Joined: Jul 18, 2006
Posts: 17
WOW cant believe that one line made the difference

THANKS ALOT Michael Dunn, you really helped me out here....



[ July 24, 2006: Message edited by: Hasnain SS ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: closing a JDialog
 
Similar Threads
Who Creates the HttpSession , User or Weblogic
JSP session tracking
Session Timeout
Closing dialog box using windows listener
gui and thread