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 / General / December 2005

Tip: Looking for answers? Try searching our database.

Draggable window only works in MS JVM, and not Sun?

Thread view: 
PilotYid - 27 Dec 2005 17:23 GMT
Hello all,
Our applet needs to support the MS JVM (and therefore Java 1.1). I have
been looking to create a draggable Window to replace a Frame that we
have since we want the frame to be 'undecorated' (no minimize button,
etc). I found some code on the Sun forums to create a draggable window
which works fine. But, I would like to create my own title bar on the
Window and only have that draggable. When I add the same listeners to
the Label instead of the Window itself, the dragging no longer work so
well in the Sun JVM, while it works fine in the MS JVM. The problem I
am seeing is that if I don't drag slowly it skips, or doesnt drag.
Note, I am only seeing this when adding the drag listeners to the Label
in the Window, but this works fine when the listeners are on the Window
itself. Also, this works fine in the MS JVM. Any ideas? For example,
the code below is what has the issue in Sun JVM, but if I replace the
'title.' to 'this.' on the 2 listeners adds, I can drag the window fine
in Sun JVM.
Thanks for you help,
Aaron

public class TestWindow extends Window {
       Label title;
       int width=300;
       int height=300;
      Point origin = new Point();

       TestWindow() {
           super(new Frame(""));

           this.setBackground(Color.blue);
           title = new Label("Draggable window");
           title.setBackground(Color.gray);
           //setLayout(new BorderLayout());
           add(title, BorderLayout.NORTH);

           title.addMouseMotionListener(new MouseMotionAdapter() {
               public void mouseDragged(MouseEvent e) {

                   Point p = getLocation();
                   setLocation(p.x + e.getX() - origin.x,
                               p.y + e.getY() - origin.y);

               }
           });

           title.addMouseListener(new MouseAdapter() {
               public void mousePressed(MouseEvent e) {
                   origin.x = e.getX();
                   origin.y = e.getY();
               }
           });

           this.setSize(width, height);
           this.show();
       }
   }
Thomas Hawtin - 27 Dec 2005 17:57 GMT
> Our applet needs to support the MS JVM (and therefore Java 1.1). I have

Eek. 1.2 came out in 1998.

> been looking to create a draggable Window to replace a Frame that we

I take it you have signed the applet?

> have since we want the frame to be 'undecorated' (no minimize button,
> etc). I found some code on the Sun forums to create a draggable window
[quoted text clipped - 9 lines]
> 'title.' to 'this.' on the 2 listeners adds, I can drag the window fine
> in Sun JVM.

>             title.addMouseListener(new MouseAdapter() {
>                 public void mousePressed(MouseEvent e) {
>                     origin.x = e.getX();
>                     origin.y = e.getY();
>                 }
>             });

I think the problem is that the event coordinates are in terms of the
parent for a normal component and the screen for a window. So you'll
need to convert the component coordinates into screen coordinates.

Even then I don't absolutely guarantee success. The event response to
components moving under the pointer is broken. In AWT due to laziness.
In Swing due to AWT being broken. In internal frames due to Swing being
broken.

Tom Hawtin
Signature

Unemployed English Java programmer
http://jroller.com/page/tackline/

Andrey Kuznetsov - 27 Dec 2005 21:26 GMT
> Even then I don't absolutely guarantee success. The event response to
> components moving under the pointer is broken. In AWT due to laziness. In
> Swing due to AWT being broken. In internal frames due to Swing being
> broken.

Why don't you go to SUN and fix all that brocken crap instead of constantly
complaining here?
Thomas Hawtin - 28 Dec 2005 14:47 GMT
>[Thomas Hawtin wrote:]
>>Even then I don't absolutely guarantee success. The event response to
[quoted text clipped - 4 lines]
> Why don't you go to SUN and fix all that brocken crap instead of constantly
> complaining here?

I have supplied some fixes to Sun.

This particular problem involves serious fixes to native code across all
toolkits, including those of licensees.

It's good to be aware of what the problems are.

Tom Hawtin
Signature

Unemployed English Java programmer
http://jroller.com/page/tackline/

Andrey Kuznetsov - 28 Dec 2005 17:37 GMT
>>>Even then I don't absolutely guarantee success. The event response to
>>>components moving under the pointer is broken. In AWT due to laziness. In
>>>Swing due to AWT being broken. In internal frames due to Swing being
>>>broken.
<snip/>
> It's good to be aware of what the problems are.

You speak here too abstract.
It makes it impossible to agree or to disprove.
However I wrote such handler and didn't encountered meanwhile any problems.

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



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.