Hallo,
I have the problem that I have a JPopupMenu object generate somewhere.
The lines of code generating and showing the menu shall not be changed.
I'd like to know the position of the the menu only be retrieving it from
its reference. Well, the JFrame may be also be known.
Is it possible to solve this problem?
For a better understanding of my problem here is a an example:
import javax.swing.*;
public final class MyFrame extends JFrame
{
public JPopupMenu generate()
{
// This method my not be changed by anyone.
JPopupMenu men = new JPopupMenu();
men.add( "hallo" );
men.add( "world" );
men.show( this, 100, 100 );
return men;
}
public void myProblemMethod()
{
JPopupMenu menu = generate();
// How can I implement the method below?
// Whatever I tried returns anything but 100,100
System.out.println(
menu.tell_me_where_I_reside_on_the_screen());
}
public static void main ( String[] args )
{
MyFrame frame = new MyFrame();
frame.setSize( 400, 400 );
frame.show();
frame.myProblemMethod();
}
}
Thank you for ideas,
Ralf
John McGrath - 10 Mar 2005 14:21 GMT
> I have the problem that I have a JPopupMenu object generate somewhere.
> The lines of code generating and showing the menu shall not be changed.
> I'd like to know the position of the the menu only be retrieving it from
> its reference. Well, the JFrame may be also be known.
menu.getLocationOnScreen();

Signature
Regards,
John McGrath