-1

I mistakenly created a Swing project, using more than 10 JFrames, every thing is working fine. but in many cases i was feeling like creating multiple JFrames was not good. and i have also figured out that creating Swing project with multiple JFrames is not a good practice too.

So now it takes lot of time to rewrite the code. but my simple requirement is, i just want to convert my JFrame to JDialog and set it as setModalityType(ModalityType.APPLICATION_MODAL);

Intact Abode
  • 382
  • 5
  • 20
  • 2
    `i was feeling like creating multiple JFrames was not good` - that is correct. An application should have a single JFrame as the main window. Child window can then be dialogs. `i just want to convert my JFrame to JDialog` - ok, go ahead an do it. – camickr May 18 '17 at 05:28
  • can i simple change my [public class SalesTasks extends JFrame] to [public class SalesTasks extends JDialog] Will it Work fine? – Intact Abode May 18 '17 at 05:44
  • 1
    Frame and dialog has the same API, so yes, you can do it. Simple write `externds JDialog` instead of `extends JFrame`. It could be a little bit difficult when you use UI-Designer, like NetBeans. – Sergiy Medvynskyy May 18 '17 at 05:47
  • I am not sure what you are asking for; as the only answer you got basically is "yes, sure". And if that is good enough already, why the need to put up such a question? – GhostCat May 18 '17 at 06:17
  • (1-) `Will it Work fine?` - try it and then tell us what happens. You learn by trying. Then if you have a problem you post a specific question stating what you did and what the result was. The forum is not here for you do ask "what if" questions. – camickr May 18 '17 at 14:19

1 Answers1

1

Finally this is what i have done.

My class extends JFrame

public class SalesTasks extends JFrame

i simply changed it to

public class SalesTasks extends JDialog

and in the constructor i just put

public class SalesTasks()
{
  setModalityType(ModalityType.APPLICATION_MODAL);
}
Intact Abode
  • 382
  • 5
  • 20