Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / GUI / September 2005

Tip: Looking for answers? Try searching our database.

How can I "glue" JDialog to an owning JFrame ?

Thread view: 
bobjan - 31 Aug 2005 13:13 GMT
I have a non-modal JDialog with a JFrame as an owner.
On a mouse right-click the dialog  becomes visible at the mouse
position. And it works fine. But when I start dragging JFrame , the
JDialog remains on the same screen position. Is there a way to "glue"
the dialog to the frame ?
Thomas Fritsch - 31 Aug 2005 14:09 GMT
> I have a non-modal JDialog with a JFrame as an owner.
> On a mouse right-click the dialog  becomes visible at the mouse
> position. And it works fine. But when I start dragging JFrame , the
> JDialog remains on the same screen position. Is there a way to "glue"
> the dialog to the frame ?

JFrame has addComponentListener and addMouseMotionListener methods,
inherited from Component. So you might want:
  yourFrame.addComponentListener(new ComponentAdapter()
  {
    public void componentMoved(...) { ... }
  });
or
  yourFrame.addMouseMotionListener(new MouseAdapter()
  {
    public void mouseDragged(...) { ... }
  });

But another question:
Why do you want to move the dialog at all, when the user moves the
frame? I think that would surprise your user, and hence would contradict
to the "principle of least astonishment"
<http://www.google.de/search?q=%22principle+of+least+astonishment%22>
And consider a desperate user's question "I just moved the dialog
totally off the screen. How can I close it now?" ;-)

Signature

"Thomas:Fritsch$ops:de".replace(':','.').replace('$','@')

Andrey Kuznetsov - 31 Aug 2005 18:47 GMT
>I have a non-modal JDialog with a JFrame as an owner.
> On a mouse right-click the dialog  becomes visible at the mouse
> position. And it works fine. But when I start dragging JFrame , the
> JDialog remains on the same screen position. Is there a way to "glue"
> the dialog to the frame ?

see http://jgui.imagero.com/tutorial.html#followHandler

BTW it easy to check dialog coordinates, so that it does not go offscreen.

Signature

Andrey Kuznetsov
http://uio.imagero.com Unified I/O for Java
http://reader.imagero.com Java image reader
http://jgui.imagero.com Java GUI components and utilities

Oliver Wong - 01 Sep 2005 19:55 GMT
> BTW it easy to check dialog coordinates, so that it does not go offscreen.

   Does it handle multi-screen environments properly? I have a dual screen
set up at home, and some of the "tricks" that some apps I've encountered
(not nescessarily Java apps) don't work very well on dual screen setups.

   I don't mean to challenge you or anything; I'm just curious as I don't
know of a solution for ensuring that something stays visible on some screen
in a multi screen setup.

   - Oliver
Andrey Kuznetsov - 02 Sep 2005 17:24 GMT
>    Does it handle multi-screen environments properly? I have a dual screen
> set up at home, and some of the "tricks" that some apps I've encountered
[quoted text clipped - 3 lines]
> know of a solution for ensuring that something stays visible on some
> screen in a multi screen setup.

it should work with any given rectangle (for example - stay at right half of
3th screen).

Signature

Andrey Kuznetsov
http://uio.imagero.com Unified I/O for Java
http://reader.imagero.com Java image reader
http://jgui.imagero.com Java GUI components and utilities

Oliver Wong - 02 Sep 2005 17:49 GMT
>>    Does it handle multi-screen environments properly? I have a dual
>> screen set up at home, and some of the "tricks" that some apps I've
[quoted text clipped - 7 lines]
> it should work with any given rectangle (for example - stay at right half
> of 3th screen).

   What if the screens don't form a triangle? For example, what if I have
one screen which has a resolution of 1600x1200, and another screen just to
the right of it whose resolution is 800x600? Then the logical layout of my
desktop might look like this:

________
|        |
|        | ____
|        ||    |
|________||____|

Which as you can see, forms a (non-regular) hexagon.

   - Oliver
Andrey Kuznetsov - 03 Sep 2005 10:42 GMT
>    What if the screens don't form a triangle? For example, what if I have
> one screen which has a resolution of 1600x1200, and another screen just to
[quoted text clipped - 6 lines]
> |        ||    |
> |________||____|

In this case you can install your own handler instead.
Or I can change my handler to accept multiple rectangles.

Signature

Andrey Kuznetsov
http://uio.imagero.com Unified I/O for Java
http://reader.imagero.com Java image reader
http://jgui.imagero.com Java GUI components and utilities

Mikael Flensborg - 01 Sep 2005 07:43 GMT
> I have a non-modal JDialog with a JFrame as an owner.
> On a mouse right-click the dialog  becomes visible at the mouse
> position. And it works fine. But when I start dragging JFrame , the
> JDialog remains on the same screen position. Is there a way to "glue"
> the dialog to the frame ?

Test it on MacOS X :-)... It works as described :-)

/Mikael


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.