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