rakhras
asked on
Position of a Java applet
Hi,
I'm writing a java applet that will be embedded
in an HTML page at an aribtrary position.
Within the java applet code, I need to know the
absolute screen coordinates of the applet.
Any ideas?
Thanks,
Ralph
I'm writing a java applet that will be embedded
in an HTML page at an aribtrary position.
Within the java applet code, I need to know the
absolute screen coordinates of the applet.
Any ideas?
Thanks,
Ralph
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Wah.., masato
It's true.. Maybe I didn't get the right meaning from
heyhey's words.. Sigh:(
Thank you masato, and thank you rakhras for posting the
question!
All the best to you all!
Zicai
It's true.. Maybe I didn't get the right meaning from
heyhey's words.. Sigh:(
Thank you masato, and thank you rakhras for posting the
question!
All the best to you all!
Zicai
ASKER
I tried component.getLocationOnScr een() in my java applet
but the J++ compiler complained that:
error J0072: 'getLocationOnScreen' is not a member of class 'Component'
any ideas?
Thanks,
Ralph
but the J++ compiler complained that:
error J0072: 'getLocationOnScreen' is not a member of class 'Component'
any ideas?
Thanks,
Ralph
Hi Ralph,
Since you are writing an Applet and the Applet class is inherited from the Component class, you don't need to put the "component." in front.
Just call the getLocationOnScreen() method as follows:
class Foo extends Applet
{
public void init()
{
Point p = getLocationOnScreen();
.........
}
}
Please try.
Since you are writing an Applet and the Applet class is inherited from the Component class, you don't need to put the "component." in front.
Just call the getLocationOnScreen() method as follows:
class Foo extends Applet
{
public void init()
{
Point p = getLocationOnScreen();
.........
}
}
Please try.
Sorry,
The sample code I've posted is not correct. Please try the following sample Applet instead.
-------------------------- ---
import java.applet.Applet;
import java.awt.*;
import java.awt.event.*;
public class Sample extends Applet implements ActionListener
{
Button button1;
public void init()
{
button1 = new Button("Location");
add(button1);
button1.addActionListener( this);
}
public void actionPerformed(ActionEven t e)
{
System.out.println(getLoca tionOnScre en());
}
}
-------------------------- ---
The sample code I've posted is not correct. Please try the following sample Applet instead.
--------------------------
import java.applet.Applet;
import java.awt.*;
import java.awt.event.*;
public class Sample extends Applet implements ActionListener
{
Button button1;
public void init()
{
button1 = new Button("Location");
add(button1);
button1.addActionListener(
}
public void actionPerformed(ActionEven
{
System.out.println(getLoca
}
}
--------------------------
ASKER
same problem ...
G:\java\MqCalendar\test.ja va(22,23) : error J0049: Undefined name 'getLocationOnScreen'
does this compile for you?
Thanks,
Ralph
G:\java\MqCalendar\test.ja
does this compile for you?
Thanks,
Ralph
I guess your J++ is not supporting the JDK 1.1 yet. Please check the supported Java version because getLocationOnScreen() method is implemented from JDK1.1. I can compile the sample applet without any problem, but I'm using Sun's JDK1.1.7B.
Hi Ralph,
I found a infomation how to use J++ with the JDK 1.1.
http://www.javaworld.com/javaworld/javatips/jw-javatip25.html
You may want to try this...
I found a infomation how to use J++ with the JDK 1.1.
http://www.javaworld.com/javaworld/javatips/jw-javatip25.html
You may want to try this...
1) You cannot do that in pure Java
2) try to use Java Script to do that.
Good luck!
Yours sincerely
Zicai