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

P

PilotYid

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();
}
}
 
T

Thomas Hawtin

PilotYid said:
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
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.
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
 
A

Andrey Kuznetsov

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?
 
T

Thomas Hawtin

Andrey said:
[Thomas Hawtin wrote:]
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?

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
 
A

Andrey Kuznetsov

Even then I don't absolutely guarantee success. The event response to
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top