Forums Register Login

Close JDialog without hide

+Pie Number of slices to send: Send
Hi

I have an application. So I use JFrame to my main GUI. And JDialog's to other GUI's. But the problem is, after I call to a sub class(they are with JDialog) and do work and close. Then again I want to call previous sub class, but there are previous data. I did set the DefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE). I can't set the DefaultCloseOperation as EXIT_ON_CLOSE. what I want to do now. I want to close the Dialog.No need to hide it.please help me.

Thank you!
+Pie Number of slices to send: Send
> Then again I want to call previous sub class, but there are previous data.

create a new instance of the sub-class each time
e.g. new MyDialog(parent);
+Pie Number of slices to send: Send
 

Michael Dunn wrote:

create a new instance of the sub-class each time
e.g. new MyDialog(parent);



Hi,

Actually I don't know how many times the user wants to open that window and do their work. Think, that window use to print a document. so first time there are no any errors. But after close that window and again open, there are previous data and user wants to clear that. But in this case my application is not a better program. Actually I don't know, what I want to do now. Please help me.

Thank you!
+Pie Number of slices to send: Send
post the code:
1) when the dialog opens the first time
2) when the dialog opens other times
+Pie Number of slices to send: Send
Hi,

Main GUI


printing GUI


If you want the data base, I can send it to your email.Please tell me that if you want or not.

Thank you!
+Pie Number of slices to send: Send
your problem would be the 'static' dialogs

here's a simple demo showing what happens


run the code, click 'show dialog', enter something into the dialog's textfield, click 'X' to close,
click 'show dialog' again and your entered text will remain (which should be the problem you describe).

now remove the word static from
static JDialog d = new JDialog();
recompile and repeat above steps, 2nd showing of dialog should have a cleared textfield (what you want)
+Pie Number of slices to send: Send
Hi Michael,

Sorry for the late. Actually you are correct but, I use this static dialogs for another activity. It is, after open a dialog i want to minimize my main application but in this case i have to identify which dialogs are opened and I have to hide them (Actually this also my fault. I didn't use JInternalFrames. But the problem is now the project is close to delivery part) .that because I use this static Dialogs. If I remove this static part how can I hide them?

Thank you!
+Pie Number of slices to send: Send
> If I remove this static part how can I hide them?

I don't know what you really mean by 'hide'

obviously, just using setVisible(false) will hide them,
but then, on setVisible(true), they'd reappear with any data still in the text components.

perhaps you should be using
dialog.dispose();
and add it at the end of a button's actionListener

alternatively you could create a 'reset' method, which clears all text from text components
and call this method from a windowListener's windowActivated()
+Pie Number of slices to send: Send
Hi Michael,

Actually you are correct. Before I used a external class and call it. Now I insert that code inside into main class.now it is work properly.Thank you very much.
I've never won anything before. Not even a tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 1671 times.
Similar Threads
Returning a value from a modal dialog?
JDialog Dilemma I Have
Double JDialog question
Using JTextArea
Issue with ComponentListener
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 29, 2024 08:39:54.