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



> Thanks Andrey for your response. Unfortunately, I am using Java 1.1
> (and need to), is there any equivalent for non-Swing?

something like this:

//since you want to use it only in event handler
//I assume that component was alredy realized - so no checking here
public static Point getLocationOnScreen(Component c) {
Point p = c.getLocation();
int x = p.x;
int y = p.y;

Container parent = c.getParent();

while(parent != null) {
p = parent.getLocation();
x += p.x;
y += p.y;
parent = parent.getParent();
}
return new Point(x, y);
}

public static Point convertPointToScreen(Point p, Container c) {
Point p0 = getLocationOnScreen(c);
p0.x += p.x;
p0.y += p.y;
return p0;
}

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


.



Relevant Pages

  • Re: Konzept eigener Thread Scheduler in Java
    ... Andrey Kuznetsov schrieb ... > http://uio.imagero.com Unified I/O for Java ... Heiner Kücker ...
    (de.comp.lang.java)
  • Re: Jpanel Dashed Border?
    ... Thank Andrey, I think I getting through it ok for a beginner just not ... I'm struggling with learning java. ... class DashedBorder { ... public void actionPerformed{ ...
    (comp.lang.java.programmer)
  • Re: viele viele paint()-Aufrufe
    ... Andrey Kuznetsov ... http://uio.imagero.com Unified I/O for Java ... Prev by Date: ... Next by Date: ...
    (de.comp.lang.java)
  • Re: KeyStroke replacement?
    ... > Thanks very much Andrey for the sample code. ... public void dispatchKeyEvent{ ... http://uio.imagero.com Unified I/O for Java ... http://jgui.imagero.com Java GUI components and utilities ...
    (comp.lang.java.programmer)
  • Re: create an image out of a portion of a JPanel
    ... > Thanks for the answer Andrey but this doesn't work. ... > trying to translate the coordinates of the target image's graphics ... http://uio.dev.java.net Unified I/O for Java ... http://reader.imagero.com Java image reader ...
    (comp.lang.java.gui)