Get a coordinates of the screen control

Hi all
I have a small problem... I would like to display a ContextMenu by clicking a button on the left. I got the part, but the context menu is displayed at the position of the mouse.
What I would like is to see the menu on the right side of the button (buttonXmax) but I can't find the absolute X the 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() {

            public void handle(ActionEvent event) {
                contextMenu.show(buttonXmax, Side.RIGHT, 0, 0);
            }
        });
        root.getChildren().add(buttonXmax);
        primaryStage.setScene(scene);
        primaryStage.show();
    }
}

Tags: Java

Similar Questions

  • How to find the coordinates of the screen control clicks?

    I would like to find the screen coordinates of the place a click / tap event occurs. So, for example, if a button is clicked, is it possible to find the x / place on screen? Or at least the command position?

    It seems to be difficult scpecially if the controls are in a ListView. The onClicked: event there is no provided location information. And if I try to join a TapHandler to the ListView it seems fire on areas non-zero.

    You can use the onTouch() signal to get the coordinates compared to itself or on the window...

    http://developer.BlackBerry.com/native/reference/Cascades/bb__cascades__visualnode.html#function-TOU...

    http://developer.BlackBerry.com/native/reference/Cascades/bb__cascades__touchevent.html

  • How to get the coordinates of the screen when they are hit.

    Hi all!

    I am a beginner on the development of blackberry, also a beginner in programming in general ^^

    I've done some app using just QML and take some C++ tutorials

    I try to get the coordinate of the screen when the user touches, I wasn't able to do that you use just QML, I found the source TouchEvent and tried to make it work on C++, to get the windowX and windowY coordinates of the touch.

    http://developer.BlackBerry.com/Cascades/reference/bb__cascades__touchevent.html

    I use the image on background to try to get contact with the event.
    So far, we have:

    PPS:

    class LostInSpace : public QObject
    {
        Q_OBJECT
    public:
        LostInSpace(bb::cascades::Application *app);
        virtual  ~LostInSpace() {}
    public slots:
    Q_INVOKABLE float screentouchY(bb::cascades::TouchEvent* event);
    Q_INVOKABLE float screentouchX(bb::cascades::TouchEvent* event);
    
    private:
    QPointer fundo;
    
    };
    

    CPP:

    LostInSpace::LostInSpace(bb::cascades::Application *app)
    
    {
    
        QmlDocument *qml =
    QmlDocument::create("asset:///main.qml").parent(this);
        qml->setContextProperty("app", this);
        AbstractPane *root = qml->createRootObject();
    
        app->setScene(root);
    
        fundo = root->findChild("fundo");
        bool res = QObject::connect(fundo, SIGNAL(touch(bb::cascades::TouchEvent*)),this, SLOT(screentouchY(bb::cascades::TouchEvent*)));
        Q_ASSERT(res);
        res = QObject::connect(fundo, SIGNAL(touch(bb::cascades::TouchEvent*)),
    this, SLOT(screentouchX(bb::cascades::TouchEvent*)));
        Q_ASSERT(res);
    
    }
    
    float LostInSpace::screentouchY(bb::cascades::TouchEvent* event) {
        return event->windowY();
    }
    float LostInSpace::screentouchX(bb::cascades::TouchEvent* event) {
        return event->windowX();
    }
    

    QML: (I'll do later animations, it's just to see if it works. I mean a "unknown simbol app" the Notecard, I thought I just had to put "qml-> setContextProperty ("app", this);  in the constructor)

    ImageView {
                    objectName: "fundo"
                    imageSource: "images/fundo1.png"
                    touchPropagationMode: TouchPropagationMode.Full
                    onTouch: {
                        tiro.translationX = app.screentouchX();
                        tiro.translationY = app.screentouchY();
                    }
                }
    

    Any help will be very appreciated!

    Thank you!

    Hey there,

    You don't need to do... You can access the 'event' TouchEvent object in the notecard: {} area QML...

    ImageView {
                    objectName: "fundo"
                    imageSource: "images/fundo1.png"
                    touchPropagationMode: TouchPropagationMode.Full
                    onTouch: {
                        tiro.translationX = event.windowX
                        tiro.translationY = event.windowY
                    }
                }
    
  • I play an online game called Last Chaos, and whenever I try to run the launcher I get a message on the screen that shows the error code 626. How can I fix this so I can play my game?

    I play an online game called Last Chaos, and whenever I try to run the launcher I get a message on the screen that shows the error code 626. How can I fix this so I can play my game?

    Hi Kerrkid90,

    Welcome to the Microsoft Answers Community Forum site!

    To launch the browser, I want to suggest you to log on as an administrator in 1. Download the game

    2. run the setup.exe file

    3. right-click on it and run as administrator.

    If it fails, suggest to run the Windows Installer Cleanup utility by visiting the following link:

    http://support.Microsoft.com/kb/290301

    In the case if the above methods fail, you can also contact last chaos community to help you fix this problem:

    http://forums.aeriagames.com/?f=6

    I hope this helps!

    Thank you best regards &,.

    Calogero - Microsoft technical support.
    Visit our Microsoft answers feedback Forum
    http://social.answers.Microsoft.com/forums/en-us/answersfeedback/threads/ and tell us what you think

  • Upgrade of Windows 8 has changed my graphics card driver, & now I get vertical bars on the screen.

    Upgrade of Windows 8 has changed my graphics card driver, & now I get vertical bars on the screen, sometimes flashing. It is sometimes difficult to use the screen, especially when it has a dark background. It is a HP Desktop quad core with card Nvidia GEForce 9600.  I tried to roll back the driver, but that didn't help. I assume that the driver I need is no longer available. I also went to Nvidia to try to find a better driver that would eliminate this problem, but no luck.  Before, this came with an update on Vista, & I could correct in the way to roll back the driver. Any help would be appreciated.

    Go to www.nvidia.com and download the WHQL 306,97 drivers updated successfully.

    With the installation of Windows 8, Microsoft provides only the "bare" minimum drivers in order to complete the installation of Windows.

  • On apple TV, I get a message on the screen that says AirPlay... Send wireless whats on your device iOS or computer etc, etc, it's very annoying.  How to stop this message from appearing?

    When I look at apple and listening to the radio to apple, I get a pop up message that says, AirPlay... Send wireless which is on our computer to the screen using AirPlay or iOS device. To find out more... etc.  It is BORING.  How can I prevent the message from appearing?

    Kind regards

    Chuck

    The Apple Tv is using the conference room. You can turn it off in the settings.

    On restrictions of airtime and the mode of the conference room on your Apple TV - Apple Support

  • Getting error while booting: "the Catalyst Control Center is not suppoerted by the version of the driver for your current graphics card.

    Original title: error message

    Whenever I turn on my computer (Windows Vista) I get the following error: "the Catalyst Control Center is not suppoerted by the version of the driver for your compatible graphics card. Please update your ATI graphics driver or enavle your ATI card using the display manager. "How can I do this? and do I do this?

    Hello

    Update the driver may solve the problem. See the following article to install/update the drivers.

    Update a hardware driver that is not working properly.

    http://Windows.Microsoft.com/en-us/Windows-Vista/update-a-driver-for-hardware-that-isn ' t-work correctly

    You can also download the drivers from AMD. Choose the appropriate brand and model of the device and download the drivers.

    http://support.AMD.com/us/gpudownload/pages/index.aspx

  • Trouble getting GPS coordinates in the Simulator

    Here is the code I use to get the coordinates of the GPS by train. It seems that every time that it expires and ends by 0 for the latitude and longitude of return even if I put together a location in my simulation-> GPS location... window and entered in the Options-> advanced-> GPS-> was cool my main application class, this function is called by a button.

    public void GetCurrentLocation() {         Criteria ct = new Criteria();            //ct.setAddressInfoRequired(false);          //ct.setAltitudeRequired(false);         ct.setCostAllowed(true);        ct.setHorizontalAccuracy(Criteria.NO_REQUIREMENT);        ct.setVerticalAccuracy(Criteria.NO_REQUIREMENT);        ct.setPreferredPowerConsumption(Criteria.POWER_USAGE_LOW);        //ct.setPreferredResponseTime(10000);        //ct.setSpeedAndCourseRequired(false);
    
            try {            myLP = LocationProvider.getInstance(ct);            myLP.setLocationListener(new myLocListener(this), -1, -1, -1);        } catch (Exception ex) {            return;        }    }
    
    public void GotLocation(Location myLoc) {        if(myLoc != null) {            QualifiedCoordinates qc = myLoc.getQualifiedCoordinates();            //Call webservice here.        }    }
    

    In the myLocListener.java

    package net.gasbot;
    
    import javax.microedition.location.*;
    
    public class myLocListener implements LocationListener{    GasBotScreen gb;
    
        public myLocListener(GasBotScreen gb)    {        this.gb = gb;    }
    
        public void locationUpdated(LocationProvider provider, Location location)    {        QualifiedCoordinates qc = location.getQualifiedCoordinates();  //I set a breakpoint here, but it rarely gets called, and when it does, the coordinates are both 0.        provider.setLocationListener(null, 0, 0, 0);        gb.GotLocation(location);    }    public void providerStateChanged(LocationProvider provider, int newState)    {
    
        }}
    

    Can you get it someone please let me know what I am doing wrong? I'll put the listener null once it gets a set location to update as I need it only once. I also tried to use the.getLocation(-1) and it does not work either. Is there something wrong with my Simulator? Or just something wrong with my code?

    I don't understand your code, in fact.  Why are reset you the listener inside the listener?

    In addition, you "eat" the exception where you get the provider. He is a likely area of failure, so I would put a trace and trace any exception.

    Another thing to try: try to set criteria to null when you get the provider: gives you the provider "by default".

  • Basic PC minimize the screen controls are missing

    Controls on all PC programs for the reduction, closure and restoration of the screen are missing in my Lightroom 5.7.1 program.  This happened only yesterday, but I don't know if I did something to do.   I am referring to the controls in the upper-right corner for all PC programs.  X to stop, "-" to reduce and the square for a custom size or medium sized box.   They still exist in other programs.  I don't see anything different in Lightroom except this basic control.   I have a PC that is running an Intel processor.   I use Lightroom for years and I've installed this version when it was released last fall.   Top left, I still see Lightroom like file, edit, Photo library, controls etc.  The result is that I can stop only Lightroom by clicking file and then clicking Exit.    How do I bring these controls in the view?   It is only in Lightroom.  If the images cut and paste work, these are the basic commands for that I'm looking:

    That's what I see in Lightroom

    Press SHIFT + F or twice.

  • How can I get permanent marker off the screen of the iPad?

    I left my nine iPad Pro 9.7 "sitting on the kitchen counter and came home today to discover our 5 year old daughter had drawn with a Sharpie (permanent marker) on a sheet of paper just above the screen. The Sharpie ink soaked through and is now all over the screen of the iPad. I tried to wipe it down with water, but that didn't work. Can what cleaning equipment I use?

    Pretty much any solvent that you could use would also eliminate the oleophobic on-screen.

    A quick search on the internet suggested on the felt of coloring with an erasable marker to dry and then wipe. I don't know if it would really work.

  • I'm trying to plug in an external monitor without success. I'm getting a signal on the screen again that there is no signal. What I'm doing wrong?

    I tried to connect another monitor using a connections of type d with an audio input jack separate pins. I have no video or sound on the new monitor even when I select the pc on the screen input.  I'm trying to hook up a monitor from 42 "to my laptop, so I can stream videos.  ANY IDEAS WOULD BE APPRECIATED CONTACT ME AT * address email is removed from the privacy * or * address email is removed from the privacy * Thank YOU

    Hello

    I suggest you to consult the following Microsoft article and check if it helps.

    Understand multiple monitors:

    http://Windows.Microsoft.com/en-us/Windows-Vista/understanding-multiple-monitors

    Add a second monitor:

    http://Windows.Microsoft.com/en-us/Windows-Vista/add-a-second-monitor

    Change the display settings on multiple monitors:

    http://Windows.Microsoft.com/en-us/Windows-Vista/change-display-settings-on-multiple-monitors

    For more information, see the following Microsoft article.

    Solving the multiple monitor problems:

    http://Windows.Microsoft.com/en-us/Windows-Vista/troubleshoot-multiple-monitor-problems

    Multiple monitors: frequently asked questions:

    http://Windows.Microsoft.com/en-us/Windows-Vista/multiple-monitors-frequently-asked-questions

    Hope the information is useful.

  • To get a filter on the screen will appear

    Generally it looks OK at first then a blue light filter appears making it impossible to distinguish the colors

    This is probably a hardware problem.   You can check if the problem occurs in safe mode to confirm.  Given that this happens after some time for the dust clogging and overheating problems.

    Is this a desktop or a laptop?
    If your desktop - if possible, try another monitor to help determine if the monitor or the video hardware is at fault.  Check the video cable also connections.
    If a laptop trying to connect an external monitor to determine if the screen or the video hardware is at fault.

  • How can I get text appears on the screen in Outlook & Internet Explorer?

    When you reply to emails in Outlook, the text I typed often does not appear on the screen or appears, usually in the part, 10 or 20 seconds after I typed.

    When I'm using Internet Explorer and typing in a forum which I am part of the text does appear not at all, not even after a delay.

    Hi, V. sirot S thank you very much for your answer. I'll put the information in my bump for later reference.

    My problem seems to have been resolved by removing the unifying device from Logitech to my computer which is under my desk & placing in the hub I have on my desk. I also removed another device on my desktop then I have now a line of sight clearer between the unifying device & my mouse & keyboard. In any case, so far, everything is fine. Thank you once again.

  • where we get Networkid, Accepoint on the remote control, local to the tuxedo Server

    Hi xu he

    We had the Client Code written in c language, his work when sending messages from Tuxedo
    He was earlier developed by others. Now we must develop with Jca adapter, for those who we need
    Networkid and Accepoint of the remote and the local, please suggest me where I
    Can get this information to the existing code, I got the Tuxedo of the remote computer Server Code and client code to the c language

    \tuxedo (main folder)
    -Ben
    -include
    -inventory
    JRE-
    -lib
    -regional settings
    -udataobj
    -uninstaler
    -registry.xml
    -set.env

    I need to use these DM_LOCAL_DOMAINS, DM_TDOMAIN, DM_REMOTE_DOMAINS, DM_LOCAL_SERVICES.
    in the configuration of the jca adapter, where can I get this information to the code existed, please suggest me.

    Thank you & & best regards
    Olivier

    Hi Olivier,.

    You have described the structure of the directory is the Tuxedo installation directory. What you are looking for is the application directory where are the application configuration files. If the application has already been configured to use the gateway of the field, there will be a file containing configuration areas. If you have configured the environment application (TUXCONFIG, TUXDIR, DMCONFIG, variable of environment, etc.), you can use the dmunloadcf command to get a text representation of the areas configuration copy if you can't find the original source for it. Which will contain all the information of domain configuration you must configure the JCA adapter.

    Kind regards
    Todd little
    Chief Architect of Oracle Tuxedo

  • getting Ref cluster from the cluster control

    I have a control ref which is introduced into a Subvi.  The control itself is part of a cluster that is an external code in VI that I work.  I want to get the property label.text of the pole of the control reference within the cluster to which I have access to.  What is the mechanism or the property of the control ref which allows me to join the cluster that contains?

    The GObject class must have a property owner. I think for the objects inside a container (such as a cluster), it returns the container. The property itself probably returns a GObject reference, so you cast down to the control class to see the label property.

Maybe you are looking for

  • black screen. no usable control

    HelloWhen I launch FF the window is black. The top of the window where the tools/address bar should be is transparent. I'm unable to open in safe mode.I can find the menu, but when I open the options, it opens also black.I have uninstalled twice. Onc

  • Satellite Pro L450D black screen and will not respond to any keys

    Hello My niece has used his Toshiba L450D for almost a year now and he really liked it, who was until last month. She turned on her laptop and when she presses the button of the mouse, the button cracked and he fell into the laptop. Now my brother co

  • MUST GET Pgm running Windows 7 with my HP Scanner 3300 not an option.

    DeadBoneHunter here. I do genealogical research and up to 2 weeks before, was able to use the old hp to run to use the HP 3300 Scanner. She is dead and will cost more difficult than what is practractial on a disable/retirement budget. The wizards out

  • Problem with to demote a domain controller

    Hi all I tried today demote a domain controller, but my domain environment is still need of this domain controller to work. I have windows Server 2003 Small Business DC as DC1 & lately I added windows Server 2008 R2 DC as DC2 in the new box as an add

  • I get a message saying "Windows cannot open the file...". »

    I had a lot of problems with infections, so I was running many scanning programs. After getting my computer almost completely cleaned, I ran the Super Anti-Spyware program.  We find 3 infections, which I'd delete (I don't have no way of knowing that