Get a Control coordinates in the Screen

Hi all,
I've a little problem... I'd like to display a ContextMenu when left clicking on a button. I've managed that part, but the context menu is displayed at the mouse position.
What I'd like is to display the menu on the right of the button ( buttonXmax ) but I can't find the absolute X value of a control.
Any ideas ?
thanks before,
Jonathan

import javafx.application.Application;
import javafx.event.*;
import javafx.scene.*;
import javafx.scene.control.*;
import javafx.stage.*;
import javafx.geometry.Side;
public class ContextM extends Application {
    public static void main(String[] args) {
        Application.launch(args);
    @Override
    public void start(Stage primaryStage) {
        Group root = new Group();
        Scene scene = new Scene(root, 300, 250);
        final ContextMenu contextMenu = new ContextMenu();
        final MenuItem menuItem1 = new MenuItem("MenuItem1");
        final MenuItem menuItem2 = new MenuItem("MenuItem2");
        contextMenu.getItems().addAll(menuItem1, menuItem2);
        final Button buttonXmax = new Button();
        buttonXmax.setLayoutX(100);
        buttonXmax.setLayoutY(80);
        buttonXmax.setText("Get context");
        buttonXmax.setOnAction(new EventHandler<ActionEvent>() {
            public void handle(ActionEvent event) {
                contextMenu.show(buttonXmax, Side.RIGHT, 0, 0);
        root.getChildren().add(buttonXmax);
        primaryStage.setScene(scene);
        primaryStage.show();
}

Similar Messages

  • HT4061 I have an iphone 3gs - the new ios 6.1 (?) upgrade has inabled my phone. I get a white apple on the screen. can't reset phone - doesn't work. what can I do besides take phone into Apple?

    I have an iphone 3gs - yes, an older iphone. 
    This morning apple had a msg that asked if I wanted to upgrade to the new ios 6.1 (?).  I said yes.  Now I can't use my phone.  I've tried hitting the power and other buttons.  I get a white apple on the screen. can't reset phone - doesn't work. what can I do besides take phone into Apple?  This *****!  I realize (now from reading internet) that my phone/system may be uncompatible.  Help!

    I have a 3GS (a true classic design!) and have upgraded it to 6.1 today.  The process did not go without a glitch - it took a few attempts to get the app's to sync but after detecting the ones causing an issue and deleting them it works - so far!  I have had issues about 50% of the numerous times a new OS is uploaded to this phone and always take the new OS with trepidation.  But at least you know there is a 3GS with 6.1 working OK.
    I suggest you do a fresh restart to the phone several times - without it being connected to the computer - to see if it gets its act together and starts.  I think it will.  Hold down the top 'power' button and front round control button until it shuts down - goes blank and dead.  Then press the top power button to re-activate - reboot - it.
    If that does not work then plug into your itunes computer, navigate in iTunes to see your iPhone and hopefully you will be able to sync it or at least 'restore iPhone' from the 'summary' tab.
    If you can not get onto the iphone perhaps you will still be able to sync if in iTunes by going - 'file' - 'devices' - 'sync iphone' or failing that try transfer purchases' and ultimately 'restore from back-up'.
    I had technical problems with my old 3GS (suffered a failed wireless antenna) so I took it to an Apple Store and they issued me with a service-replacement/reconditioned phone for a very modest charge.  So if worst come to the worst get a new phone that way!

  • Mouse coordinates on the screen

    is it possible to get mouse coordinates on the screen? i want to make a program which makes screenshots of areas on the screen and i want use the mouse to mark them.
    how could i do that? is it possible to get mousecoordinates even if the mouse is outside the java JFrame?
    there must be a way! i searched in the forum but i found no answer.
    please don't tell me i have to use jni, the app should be platform independent.

    Yeah, basically there's no way to do this. This should be requested if it hasn't already (too lazy to check). It's not hard for sun to add, they just need to add it. Ok, anyway, I looked into it and see if there was a way to do this even somewhat reasonably in Java. I was very disappointed. I pretty much had no luck, but I did get a lame way of implementing this :P After some thought, this is what I ended up with:
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class MousePosition extends JFrame implements MouseMotionListener
        private int x = 0;
        private int y = 0;
        private boolean isAP = true;
        public MousePosition()
            setSize(300, 300);
            setLocation(200, 200);
            addMouseMotionListener(this);
            addMouseListener(new MouseAdapter()
                public void mousePressed(MouseEvent e)
                    isAP = false;
            setVisible(true);
            try
                Robot r = new Robot();
                r.mouseMove(getLocation().x + 50, getLocation().y + 50);
                r.mousePress(InputEvent.BUTTON1_MASK);
            } catch(AWTException e) {}
        public void mouseDragged(MouseEvent e)
            System.out.println(e.getX() + getLocation().x + ", " + (e.getY() + getLocation().y));
        public void mouseMoved(MouseEvent e) {}
        public static void main(String[] args)
            new MousePosition();
    }So it'll "lock" the program getting the absolute coordinates until you press the mouse, then you're free to do what you want. You could also do this with keyPressed or anything else you want. JNI would be the real solution as of now, until then I think sun should address the problem.

  • This is about iPhoto:  I need to print the FULL IMAGE as shown on the screen:  the image is SQUARE (equal on four sides).  iPhoto keeps cropping it into a rectangle - THIS IS NOT ACCEPTABLE!  How do I get what I see on the screen in print form???

    I need to print the FULL image as shown on the screen - the image is SQUARE (equal on all four sides).  iPhoto keeps cropping it into a rectangle - this is not acceptable!  How do I get what I see on the screen into print form?

    Like Terence explained:
    OT

  • HT4623 how do I get my safari back on the screen on my iphone ?

    how do I get my safari back on the screen on my iphone ?

    settings - general - reset - reset home screen layout.

  • I downloaced ios6 but most of my apps dissapeared. How do i get my apps back on the screen?

    I downloaced ios6 but most of my apps dissapeared. How do i get my apps back on the screen?

    Just go to the App Store and look at purchased on all
    They should all be there and you just download them again
    Good Luck

  • I cannot activate the screen saver. My operating system is Mac OS X version 10.6.8. The screen message says 'Please contact the vendor to get a newer version of the screen saver'

    When I try and activate my screen saver the following message appears
    Please contact the vendor to get a newer version of the screen saver
    My operating system is Mac OS X  version 10.6.8

    To begin with, you have the wrong forum - the iMacs covered by this forum were discontinued in 2005 and are incapable of running OS X 10.6.x
    Try either iMac (Intel) or Snow Leopard forums.
    To get more help, contributors will need to know what screensaver you're trying to use - is it one downloaded from the internet or one of the OS X default set?

  • What is the temperature limit of the finger to work on iPhone touchscreen? I'm asking this, because I've noticed that when my finger gets too warm (about 104oF) the screen of my iPhone 5 doesn't recognize its touch. Thank you.

    What is the temperature limit of the finger to work on iPhone touchscreen? I'm asking this, because I've noticed that when my finger gets too warm (about 104oF) the screen of my iPhone 5 doesn't recognize its touch. Thank you.

    I understood. Emphasizing that this is still a guess, when you touch the screen it compares your fingerprint at that time to the one you originally recorded. The fact that the finger is warmer may have a small effect on the fingerprint making it appear different than the original colder one. Temperature differences cause things to expand and contract and that may be having an effect on the comparison. You could try recording a fingerprint after doing what you are doing and then see if it will be recognized when you do the same thing to log into the phone. I know that prior to iOS 7.1 for a few minutes after I would wash my hands the phone had difficulty recognizing the fingerprint. Don't know if it was temperature or moisture that caused the temporary change induced by the hand washing. That improved with version 7.1 I think.

  • TS3274 The volume control stays on the screen

    The volume control stays on the screen.

    If the volume is working properly meaning if you do have sound and you can adjust the volume up and down, try this now.
    Reboot the iPad by holding down on the sleep and home buttons at the same time for about 10-15 seconds until the Apple Logo appears - ignore the red slider - let go of the buttons.

  • I have problem with my iphone 5 when I talk my ear allways tuch the screen and get it on no sound, the screen are not lock, is that possible

    I have problem with my Iphone 5, when I talk my ear allways tuch the screen and get it on no sound, the screen are not lock, is ti possible to lock the screen when incomming an outgoing call going on

    Hello Mogulman46,
    So what that means is when you have Do Not Disturb turned on, you may have an alert depending on the setting and how you are using your iPhone. So if it is set to Always, then that means that no matter what, your iPhone will not be notified. If it set to Only while the iPhone is locked, then that means that you will not get notification when your iPhone is locked but you will get notifications if your iPhone is being used. Also keep in mind the settings All Calls From can be set to certain contacts like Favorites, Everyone or no one. If you are using Do Not Disturb and you do not need it, then turn it off. 
    Use Do Not Disturb on your iPhone, iPad, or iPod touch
    http://support.apple.com/kb/ht5463
    Regards,
    -Norm G. 

  • I received an Ipad Air 2 on Jan 6 2015.  I can't get to come on.  The screen is black.  Help!

    I received an Apple Ipad air 2 on Jan 6, 2015.  I cannot get it to come on today.  It is fully charged and I only get a black screen.  Help!

    Had a similar problem with an Air 2.  For some reason, the battery had gone to 0 from 50% overnight, locked and idle.
    Apparently, plugging it in with a 0 battery takes about 15-20 minutes to get to a point where the screen will show anything (about at the 2% battery level).
    I had tried everything else (reset, power off, ...).  Be sure you're using an Apple charger and Apple cable and try plugging it in and waiting a while.
    It's been OK for the last two weeks.

  • Why do i need to restart my imac everyday like ten times to get it to work, also the screen displays little digital squares.

    Why do i need to restart my imac everyday like ten times to get it to work, also the screen displays little digital squares.

    Hi Matt,
    I purchased my imac in November of 2010 and below is a cut and past from Hardware overview. It has 1 TB hardrive, with 670 GB free. When i start up in the morning, it boots normal then freezes. Half the time i can get it to restart before it freezes, other half i have to power down then restart. At the same time throughout this process the little pixel squares show up sometimes in a single line or two aross the screen, then sometimes more random. After about 7 times of rebooting, everything runs fine for the day with no weird pixels. then i shut down at night, and start the porcess over in the morning. Thanks for your help!
    iMac
      Model Identifier:
    iMac11,3
      Processor Name:
    Intel Core i5
      Processor Speed:
    2.8 GHz
      Number Of Processors:
    1
      Total Number Of Cores:
    4
      L2 Cache (per core):
    256 KB
      L3 Cache:
    8 MB
      Memory:
    4 GB
      Processor Interconnect Speed:
    4.8 GT/s
      Boot ROM Version:
    IM112.0057.B00
      SMC Version (system):
    1.59f2
      Serial Number (system):
      Hardware UUID:
    AF510593-DDA2-513F-AE18-631B726F0BB1

  • I have a 27" imac. The screen is making a hissing noise that seems to get worse as I brighten the screen. Any thoughts?

    I have a 27 inch Imac that is making a noise that gets worse as I increase the screen brightness. Any thoughts?

    Did you resolve this issue? My iMac 27 just started making an irritating noise that decreases/increases when I lower/higher the brightness. The noise also increases when i scroll documets and webpages.

  • Howto get X/Y coordinates with the mouse of a PDF opened

    Hello, I am making a simple application that show the X/Y coordinate of the
    mouse when it is over a opened PDF file.
    How can I do it?, how can get the X/Y coordenates of the mouse pointer when
    it is over it??, and capture it when the user do click???
    I dont want to get the XY cooridnates of a text or similar ... I need to get the X/Y
    coordinates where the user make click in the PDF for modify it and place a rectangle.... I have made the
    rectangle function and It works fine, but I need to know where the user want
    to put the rectangule ..., now the user simply write it on a text box (X/Y)
    and works fine, but I would like to automatizate it and that if the user
    made click over the PDF capture the XY coordinates of the possitionand fill
    in the textbox automatically the x/y coordinates.
    Any example in visual studio c#???... I open the PDF on a webBroser control
    Please, any help would be very aprecciated

    Ok, I dont have any problem in write it in c/c++ .... do you know
    a simple plugin example or what function should I need to use for get the
    x/y cooridnates of the mouse over a opened pdf?
    Thanks a lot

  • How can i get rid of condensation behind the screen?

    Hi, my iPod works fine, but after leaving it in my bag during footy training outside and it then raining, it has condesation marks all over the screen. The functionality of the iPod is fine but it is very irratating having these marks over the screen. They are not strong enough to make reading the iPod hard but obviously I'd like to get rid of them.
    I understand as it is a matter involving water my warranty won't cover it?
    Is there anything else I can do? How hard is it to take it apart?

    There are some liquids that you can buy in the shops which makes you clean those marks from your iPod. You can find them in the Apple Stores and most of the computer shops.

Maybe you are looking for

  • Error starting application in Weblogic Server 10

    After deploying to a workshop server instance which supports beehive, I'm getting this stack trace relating to weblogic.jar. I would appreciate any help here as I'm stuck. weblogic.application.ModuleException:      at weblogic.servlet.internal.WebApp

  • Material on layout of adobe forms

    hi all, i need to develop adobe forms...i have never done adobe forms before this..except the layout part other things are almost clear..in help.sap.com there is no details on layout..i want to know about body pages,master pages,subforms,content area

  • ISE - sponsor guest portal with smartcard authentication

    Team, any support for sponsor guest portal authentication with the smartcard? If not then can someone plese create feature request to Cisco, smartcards are being rolled out more and more. Bilal

  • Color Management in Mail Stationery Mixes Color Profiles

    Using Leopard's new Stationery in Mail, I drag my own pictures to the drop zones in the stationery and Mail composites them with the stationery's background into an image that should blend seamlessly with the rest of the email. The problem is that Ma

  • All right what happened, and how do i fix it?

    I backed up all my music to cd's, I had to re-install my OS X software, and when I put back the songs into iTunes it doesn't show the name of the song, or its picture anymore, it only says, tarck 1, 2, 3 etc.... What can I do?