-2

I have a JDialog and I have it parented to a JFrame. I can move the dialog outside of the JFrame and I want to remove it.

Visual example of the Problem

What I want to happen: Fix

mKorbel
  • 109,525
  • 20
  • 134
  • 319
Jama
  • 1
  • 1
  • 1
    Patronizing the user is generally a bad idea, it only leads to a worse user experience. If I want to put some dialog on my second monitor while looking something up I need to answer it, let me do so - what's the harm? Inventing new user paradigms for no good reason (name at least one major program that does something like this) is a really, really bad idea, it will only confuse your users. – Voo Sep 01 '13 at 15:19

2 Answers2

0

You can add a component listener to the JDialog to implement the componentMoved and componentResized event and when the bounds of the new position is outside your wanted bounds of the associated JFrame you can call the setBounds method to relocate the JDialog...7

GerritCap
  • 1,606
  • 10
  • 9
  • I've never worked with component listeners, could you please give me an example or direct me to a tutorial? – Jama Sep 01 '13 at 15:57
0

Yes you can, please follow this instruction for futher information. Keep Coding! :)

Yohanim
  • 3,319
  • 9
  • 52
  • 92