File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

closing a JDialog

 
Hasnain S
Greenhorn
Posts: 17
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 15150
31
Android IntelliJ IDE Java Scala Spring
 
Hasnain S
Greenhorn
Posts: 17
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 17
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
well i still havent solved the problem so if anyone can help...please do so...


bump
 
Michael Dunn
Ranch Hand
Posts: 4632
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 17
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 17
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i have sent at ur email

plz chek it
 
Michael Dunn
Ranch Hand
Posts: 4632
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 17
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 17
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4632
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 17
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic