1

In the application we are designing, we have a class that inherits from JFrame. This class launches a derived class of JDialog that is modal in order to capture some input from the end user. This derived class now needs to launch a different JFrame due to a new requirement.

The problem we are facing is that if we set the JDialog to be a non modal dialog, then the data from the JDialog does not get saved when we hide the dialog using setVisible(false).

On the other hand if we keep it modal, the new form doesn't get launched and is always hidden.

Any ideas why modality affects the dialog object?

I was FINALLY able to fix this by setting the Application Exclusion modality type in the new Frame i'm popping up! Thanks everyone for all the help!!

  • *if we set the JDialog to be a non modal dialog, then the data from the JDialog does not get saved when we hide the dialog using setVisible(false)* I don't think modality of dialog affects how you get data from it and process it. – Harry Joy Sep 25 '13 at 12:32
  • Hello Harry,I didnt think so either, which is why i never even looked into that option, but apparently, when I hide the dialog, the object is also getting destroyed hence i lose the data. I cant explain it any other way! Hence my conundrum, the processing is identical in both cases, but in one case it works and in the other it just doesnt! – user2815224 Sep 25 '13 at 12:34
  • New frame should appear after closing dialog or during working with this dialog? – Piotr Müller Sep 25 '13 at 12:47
  • The new frame should appear when wrking with the dialog, it was fixed by setting the application exclusion type in the new frame. – user2815224 Sep 25 '13 at 13:18

1 Answers1

0

I'd say the modality is not, or only part of, the problem. The questions is how you save your data. This does not automagically happen when you hide the dialog, does it? You most likely listen to some event or button action to extract and save the data from the dialog. So you should review your mechanism that extracts and saves the data and see on what it relies that is not triggered when modality is off.

Vampire
  • 35,631
  • 4
  • 76
  • 102
  • Unfortunately the application was designed by someone else and we didnt have much control over changing the elements! Thanks a ton for your help though!! – user2815224 Sep 25 '13 at 13:21
  • Even if you don't have the possibility to change the code, you might be able to look at it to find out why it doesn't work and how to make it work without changing that code. It is hard to be more concrete without actually being able to look at the code. If you need further help, you might be able to provide a showcase project with sample code that shows the same behaviour. If my answer already helped you to solve your problem, it would be nice if you accept it as right answer. :-) – Vampire Sep 27 '13 at 11:10