Re: Draggable window only works in MS JVM, and not Sun?
- From: "PilotYid" <usenet@xxxxxxxxxxxx>
- Date: 28 Dec 2005 07:12:52 -0800
Thanks Andrey for your response. Unfortunately, I am using Java 1.1
(and need to), is there any equivalent for non-Swing?
Thanks
Aaron
Andrey Kuznetsov wrote:
> > 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();
> > }
> > }
>
> you should convert all coordinates to absolute (screen) coordinates
> SwingUtilities.convertPointToScreen().
>
> --
> 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
.
- Follow-Ups:
- Re: Draggable window only works in MS JVM, and not Sun?
- From: Andrey Kuznetsov
- Re: Draggable window only works in MS JVM, and not Sun?
- References:
- Draggable window only works in MS JVM, and not Sun?
- From: PilotYid
- Re: Draggable window only works in MS JVM, and not Sun?
- From: Andrey Kuznetsov
- Draggable window only works in MS JVM, and not Sun?
- Prev by Date: color pallet
- Next by Date: Re: Draggable window only works in MS JVM, and not Sun?
- Previous by thread: Re: Draggable window only works in MS JVM, and not Sun?
- Next by thread: Re: Draggable window only works in MS JVM, and not Sun?
- Index(es):
Relevant Pages
|