0

I can't hide or dispose JDialog, If I set JDialog with Boolean Modal = true; otherwise if I set JDialog with Boolean Modal = false I can hide or dispose, but then overriden method paint() doesn't do what I want.

I Tried to SetModal(), but it doesn't succed. I forgot I had extended JPanel on JDialog.

NewJDialog dialog = new NewJDialog(this, true); // here 

in NewJDialog I have private NewJPanel newJPanel1; which has overwritten method paint in NewJPanel

mKorbel
  • 109,525
  • 20
  • 134
  • 319
  • 1
    this sound me like as nonsence, for better help sooner post an [SSCCE](http://sscce.org/), short, runnable, compilable, just about empty JFrame and empty modal JDialog caused with a.m. issue – mKorbel Sep 14 '13 at 14:42
  • Please try to add a demo of your code – fujy Sep 14 '13 at 14:45
  • This wonderful [answer](http://stackoverflow.com/a/18107432/1057230), I hope will surely address your concern :-) – nIcE cOw Sep 14 '13 at 15:39
  • Incidentally, "Swing programs should override `paintComponent()` instead of overriding `paint()`."—[*Painting in AWT and Swing: The Paint Methods*](http://www.oracle.com/technetwork/java/painting-140037.html#callbacks). – trashgod Sep 15 '13 at 03:25

1 Answers1

2

Let your panel be a listener to the modeless dialog, as shown in this example.

Community
  • 1
  • 1
trashgod
  • 203,806
  • 29
  • 246
  • 1,045
  • +1 for this new approach, though my vote will come in some time (Limit gone for the day __:(__) Learning many new thingies, now a days, surely this thingy (pattern) is something I just learned quite recently :-) – nIcE cOw Sep 14 '13 at 15:41
  • 1
    @nIcEcOw: Thanks for looking at this (now closed) Q&A; the user may not realize that `setModalityType(MODELESS)`, formerly `setModal(false)`, leaves the observer pattern implementation to the application. – trashgod Sep 14 '13 at 17:10