Positioning of the Popup control on the scene (Notification control)

Hello everyone.

I am creating a JFX control that will provide an easy way to display notifications (i.e. control notification). This control extends to the javafx.stage.Popup (complete code on https://bitbucket.org/scekics/jfxnotification) and all is fine - except for positioning.

I tried to replace the
public void show(Window owner)
method so that the default Notification is positioned in the top box in the center of the stage/scene (the most logical place, in my opinion), but I just can't do things. I tried different formulas, properties, scene and calculations based on stage, but in wain.

This is the current method:
@Override
    public void show(Window window) {
        Double sceneLayoutX=window.getScene().getRoot().getLayoutX();
        Double sceneY=window.getScene().getY();
        Double sceneWidth=window.getScene().getWidth();
        Double windowWidth=window.getWidth();
        Double myX;
        myX=(windowWidth/2.0)-300.0+sceneLayoutX;
        setX(myX);
        setY(sceneY+30.0);
        super.show(window);
        initAutomaticClosing();
}
Please note that these dimensions hardcoded are an act of a desperate man - so don't judge. :)

Each recommendation (concerning this problem and Notification control in general) is welcome. Thank you!

Published by: scekics on January 13, 2013 04:27 - corrected URL

I think that the problem is that x and that you are calculating in the owner window are coordinates of the content compared to the window; Whereas x and y are you computer to switch to (...) setX and setY (...) are screen coordinates.

How about this? The idea is to calculate the (screen) x coordinates of the notification of the (screen) x coordinates of the window, the window width and the width of the Notification itself (Similarly for y). I am sure you have understood, the width of the Notification is not calculated until after that he is shown, so I used links and Auditors to keep everything in harmony. This centers the Notification, which is not quite what you asked in terms of coordinates, but you can adjust if necessary.

I'm not sure what happens if one of the overloaded methods show() is called. You can override those and to call this method.

    @Override
    public void show(final Window window) {
      final DoubleBinding xBinding = new DoubleBinding() {
        { super.bind(window.xProperty(), window.widthProperty(), widthProperty()); }
        @Override
        protected double computeValue() {
          return window.getX() + (window.getWidth() - getWidth())/2 ;
        }
      };
      final DoubleBinding yBinding = new DoubleBinding() {
        { super.bind(window.yProperty(), window.heightProperty(), heightProperty()); }
        @Override
        protected double computeValue() {
          return window.getY() + (window.getHeight() - getHeight())/2 ;
        }
      };
      final ChangeListener xUpdateListener = new ChangeListener() {
        @Override
        public void changed(ObservableValue observable, Number oldValue, Number newValue) {
          setX(xBinding.get());
        }
      };
      xBinding.addListener(xUpdateListener);
      final ChangeListener yUpdateListener = new ChangeListener() {
        @Override
        public void changed(ObservableValue observable, Number oldValue, Number newValue) {
          setY(yBinding.get());
        }
      };
      yBinding.addListener(yUpdateListener);
      this.addEventHandler(WindowEvent.WINDOW_HIDDEN, new EventHandler() {
        @Override
        public void handle(WindowEvent event) {
          xBinding.removeListener(xUpdateListener);
          yBinding.removeListener(yUpdateListener);
        }
      });
      super.show(window);
    }

Tags: Java

Similar Questions

  • How to make multiple "BOLD" text, for example the positions of the scene, or the names of the characters?

    How to make multiple "BOLD" text, for example the positions of the scene, or the names of the characters?

    You can do this by changing the model of the document.

    Open the document, go to Edition-> model. A dialog box will launch that will have some element types on the left and its properties on the right.

    Select Heading (or Character name) stage left. On the right, go to the 'Text' tab and click on the "BOLD" checkbox.

    Press OK.

    I hope this helps.

    See you soon,.

    Sunny

  • Not relative to the scene symbol

    I have a symbol that moves from right to left on a trajectory - the entire width of the screen.

    I get his position as my main script like this:

    var Sy = sym.getSymbol("symbol").getSymbol ("nestedsymbol")

    sy.getSymbolElement () .position (.the)

    I want the symbol to scroll through the edge of the screen. I allow him to do, but so - say, I allow it to scroll 200px off the coast of the left side of the screen, its position is reported compared with the above code. Thus, he always brings 200 more to the left as it is.

    Global is defined. Should it not report its position with the scene?

    (if I move the object, so instead of finishing 200 pixels wide to the left of the screen, but at 0, then it reports its position as planned).

    Thank you

    I have it working.

    The symbol has an animation strip inside. The final Strip place 150px to the right of the left edge of the animation.

    If I do the animation of void * finishing * on the first picture - it suits him.

  • Serious accidents with control of the expression spacing based on z-position of the layer

    I have massive crashes when you use this script expression below. I have just a text layer where I control the depandend letter-spacing of the current z position. From z = 0 to-500 (directly in front of the camera), the values are transformed by easyOut() from 0-10. So far, that's all.

    Now when I duplicate this line of text several times and start to change its position, then the accident happens. Text layers more I have the sooner the crash. This occurs when the edition therefore not made involved. In the preview is the applied standard rendering engine.

    Unfortunately, there is no specific error message - it indicates just that AFX no longer works and is now closed.

    My system features:

    I have 8 GB of RAM and 10 GB disk cache. That should be enough for a text flying around.

    I use the latest Version of CC of AFX 2015.1 13.6.1.6 running on Windows Ultrabook (Lenovo Yoga 1) 8.1. No CUDA detected so the preview is rendered by the CPU.

    Anyone has an idea why this happens? Help is very appreciated.

    max_spacing = 10;
    z_position = transform.position[2];
    var new_spacing = easeOut(z_position, -500, 0, max_spacing, 0);
    text.animator("Animator 1").property.trackingAmount = new_spacing;
    

    This is my test scene:

    http://Augenpulver-design.de/Exchange/tmp/AFX_Expression_Crash_Scene.zip

    You create a hole of logic by referencing the layer itself probably. Should not happen, then I would call it a bug. Probably to do with flaky matrix code also used to smack and a few other things. Try to use a Null value and parent the text to it. This would work much better.

    Mylenium

  • Calendar AS3 with the position of the mouse control.

    Hi everyone, thanks in advance to the community for any help you might be able to offer, it's all the incredably appreceated.

    It is a problem which had scratching me my head for months and be a facilitator, was really stretching my AS3 skills a bit.

    I create an interactive story of sorts and what is needed is to use the horizontal position of the mouse to scroll forward or backward on a timeline that is, when the mouse is in the dead center of the stage that the playhead does not move, but once he deveates right centre of the read head moves forward and plays the animation and a Once it moves to the left the read head begins to move backwards.

    Ideally I would have an acceleration effect, where the animation scrolls while the timeline at a minimum speed when the mouse is always close to the Center but at a faster rate once it is reached the edges, but right now, it is a secondary concern.

    There are also keys to move through various scenes, I can code myself, I only mention this in case it affects the rest of the code.

    Thanks for you help and any solutions or navagating alternitive methods a timeline are welcome indeed

    I'll be sure to pass on the karma to an area im more familiar with.

    var mc:MovieClip = MovieClip (this);  //<- timeline="" you="" want="" to="" control="" with="" mouse="">

    var maxScrollSpeed:int = 100;  / s max for mc above

    var m:Number;

    var b:Number;

    var prevFPS:int;

    paramF(0,-maxScrollSpeed,stage.stageWidth,maxScrollSpeed);

    this.addEventListener (MouseEvent.MOUSE_MOVE, scrollF);

    function scrollF(e:Event):void {}

    var fps:int = Math.round(m*mouseX+b);

    {if(prevFPS&&prevFPS!=FPS)}

    {if(FPS!=0)}

    {if(FPS>0)}

    playF (mc, mc.currentFrame, mc.totalFrames, fps);

    } else {}

    playF(mc,mc.currentFrame,1,-fps);

    }

    } else {}

    stopF (mc);

    }

    }

    prevFPS = images/second.

    }

    function playF(mc:MovieClip,_m:int,_n:int,_fps:int):void {}

    var playFFF2:Function = {function(mc:MovieClip):void}

    If (mc.m

    mc.nextFrame ();

    } else {}

    mc.prevFrame ();

    }

    If (mc.currentFrame == mc.n) {}

    clearInterval (mc.int);

    }

    updateAfterEvent();

    };

    MC.m = m;

    MC.n = n;

    MC. FPS = FPS;

    mc.gotoAndStop (mc.m);

    clearInterval (mc.int);

    MC.int = setInterval (playFFF2, 1000/mc.fps, mc);

    }

    function stopF(mc:MovieClip):void {}

    clearInterval (mc.int);

    }

    function paramF(x1:Number,y1:Number,x2:Number,y2:Number):void {}

    m =(Y1-Y2) /(x1-x2);

    b = y1 - m * x 1;

    }

  • position of the control

    Hi all

    I need to know the position of the control on the Panel frontal wrt the screen and not the Panel. Currently, if I have a chart on a FP, and I use the 'Position' property, it returns the top and left position of the wrt Control Panel. I need the position of the control on the screen and not the Panel.

    How can I get this information?

    Thank you

    Ritesh

    You have to take the position of the front panel (use the FP Panel limits) and then take the position of the control so add the top and left values of positions, there you go you've got the position of the order with respect to the screen.

    Note: All doing this keep the origin of the left and top FP exactly meets the edges of the Panel so that you can get the actual position.

  • How can I determine the position of the mouse in a 2D image control

    I have an app where I would like the user to be able to interact with objects in a 2D image control with the mouse.  To do this, I need to translate between the screen coordinates, which are transmitted with the events of mouse and in the control of 2D image.

    The problem that I am running is that I can't find a way to determine the screen coordinates of the top left corner of the drawing/client of the 2D image control area.  I tried to use the 'Position' of the image control property, but this results in a mismatch because of the difference between the upper-left corner of the image control (including the label, etc.) and the upper left corner of the drawing area.  See attached VI.

    Does anyone know how to get the coordinate of the screen from the corner of the drawing of the control of the photo area?

    Mark Moss

    I tend to use the mouse in the image control property to get the position.  Deals with things like the passage of origin for you.

  • Tab control position in the center of the screen

    Is it possible to place a tab control, so that it is always at the center of the screen (even if the user changes the window size)?

    I tried to use the size of panel properties to determine the Center, then the reference position of the tab control. But it seems to me that his position is relative to its position (?) start.

    Is there a way to position it related initially to the Group?

    Thanks in advance.

    SSK

    It is simple. Unless I get it, isn't this what you need?

  • need suggestions on the way to a position on a motor control with current continuous

    Hi, I'm a newbie with labview

    I'm doing a position on current motor control continuous. I use a USB 6259 to generate an output voltage and acquire the angular position of a coder.

    I enclose my system of proaction

    How can I transform into a feedback system, with a given reference signal?

    Thank you

    The "cascade dc motor speed regulator" example uses the Control Design and Simulation Module, and it is thought to control a motor which is simulated. Since you have to acquire data from a real system the standard while loop is correct.

    With respect to the operation of PID control, you can take a look at the following examples:

    Control input PID Counter

    PID Control-single channel

    PID Control-Advanced

  • How can I disable the popup control in the user account that appears on my desktop to allow or reject the changes when I open a program without changing my user account settings.

    Original title: uac

    How can I disable the popup control in the user account that appears on my desktop to allow or reject the changes when I open a program without changing my user account settings.

    You want should not do that. These pop-up UAC is there to ensure the interaction of the user before executing a command or program. Disabling, allows even unwanted programs (= malware, viruses, Trojans) go ahead and implement themselves on your system without being noticed.

  • Control a movieclip with the position of the mouse

    Hello everyone,

    I worked on a small project at work, I'm trying to controll a movieclip which consists of 60 still images of an aircraft (total 120 frames) that when played will show a view of 360 degrees of said aircraft. I can make it work with buttons, but ultimately I want to control the movieclip by moving the mouse. If anyone can help, that would be wonderful. Thanks in advance.

    Here is the code:

    import flash.events.MouseEvent;

    AC. Stop();

    stage.addEventListener (MouseEvent.MOUSE_MOVE, mouseMove);

    function mouseMove(event:MouseEvent):void
    {
    If (mouseX > 800 & & (mouseX < 1600))
    {
    ac.gotoAndStop (ac.currentFrame + 1);

    if(AC.currentFrame == 120)
    {
    ac.gotoAndStop (1);
    }
    }
    on the other
    {
    ac.gotoAndStop (ac.currentFrame - 1);

    if(AC.currentFrame == 1)
    {
    ac.gotoAndStop (120);
    }
    }
    }

    Using this code, the SWF file acts ok without error. I can do the movieclip play in any direction, however, when you move the mouse in the opposite direction that the movieclip continues to play forward or backward.

    Thank you

    Tommy

    There are at least two ways you can address this problem and they both require to control the position of the mouse more closely.  Now you have a general... If it's 800 > ahead and if his < 800="" step="" back,="" but="" when="" you="" step="" back="" from="" 1200="" to="" 1199="" you="" are="" still=""> 800, if you take one more step.  You need to either follow the change in mouse position or the position of the mouse to determine the framework of movieclip.  The second one is probably easier to design and will also be more accurate if the intention is to have a rotation for a displacement of the full scale of the mouse... otherwise you could just step back of a pixel at a time and in 120 pixels of movement... that might be what you want-the purpose is not explained in what you provided.

    (1) following the change of the position of the mouse - you must keep track of where the mouse was against where the mouse is when you check it... if(previousMouseX > currentMouseX)... you need to make the animation go back, etc...

    (2) with the position of the mouse to determine the frame movieclip - divide 120/1600... This is the number of images per pixel.  Take the current value of mouseX and multiply by that and make it an integer - go to this issue of image in the animation... simplifies this entire function similar to...

    function mouseMove(event:MouseEvent):void {}

    ac.gotoAndStop (int(mouseX*120/1600));

    }

    but refine to remember that there is no image 0

  • How are supposed to do a 3-d rotation icon after Photoshop CC removed the scene 3D Position?

    I read on how to be a part of my logo into an icon of spinning, but all tutorials involve the use of the adjustment of the Position of the 3D scene in the timeline panel. However, a recent update Adobe removed that feature. Is there another way to do this? I can't the keyframes to work in the same way by using one of the other options, the position of the camera for example, 3D rendering 3D, settings, position, etc. Whenever I put a keyframe that older resets. Any help would be greatly appreciated, thank you.

    I more or less found a way to do it. Use Mesh 3D keyframes in the layer of the timeline of the object you want to animate.

  • position of the object controlled by time

    So, I want to control the position of a white box using expressions because I can't use the keyframe I want (or I'm just stupid).

    I already have

    a = thisComp.layer("White_box").effect ("sound keys") ("Output 1") * 1;

    b = thisComp.layer("White_box").effect ("sound keys") ("output 2") * 1;

    c = thisComp.layer("White_box").effect ("sound keys") ("output 3") * 1;

    y = a, b, c;

    value - [0, y];

    in the expressions of the white box, so what can I do now to control the position of the box with the time?

    Select the layer with the expression, then the effect > options for expressions > Slider control.

    Then change the first part of the expression:

    mult = effect ("Slider Control") ("Slider");

    In addition, y = a, b, c will define just y of c, not of a + b + c.

    Dan

  • How can I position MCs in the scene as words wrapped in a page? Mathematical problem.

    Hello world

    I am trying to position a few MCs in rows in the scene (dynamically created MCs) in such a way that, when they reach a max width they jump up to a line, such as words wrapped in a page with left alignment, or to explain, as the scheme of image attached. Each MC has a different width.

    I tried a lot of things without success. But I guess that I'm almost there. Right now I use a table that retrieves each width of MCs and another who gets the sum of the widths.

    Here is my code, important elements in red:

    CREATE MENU CONTAINER.

    var menuContainer:MovieClip = new MovieClip();

    menuContainer.x = 10;

    menuContainer.y = 500;

    addChild (menuContainer);

    CREATE IMAGES CONTAINING MC.

    var imagesContainer:MovieClip = new MovieClip();

    imagesContainer.x = 10;

    imagesContainer.y = 10;

    addChild (imagesContainer);

    CHARGERS IMAGE.

    var imagesLoader:Loader;

    var bigImagesLoader:Loader;

    TABLES.

    var imageLoadArray:Array; stores the respective URL of each image in each button

    function sum(array:Array,_ini:int=0,_fin:int=-1):Number {/ / function to sum bays}

    fin = (is-1)? array.length: end;

    var sumArrays:Number = 0;

    for (var u: uint = ini; u < fin; u ++) { }

    If (typeof (array [u]) == 'number') { }

    sumArrays += array [u];

    }

    }

    return sumArrays;

    }

    var imgPosArray:Array = new Array (); creates the table that defines the position of the images in the Gallery

    var imgPos:Number;

    LOAD THE XML.

    var xmlLoader:URLLoader = new URLLoader();

    xmlLoader.addEventListener (Event.COMPLETE, whenLoaded);

    xmlLoader.load (new URLRequest("XML/roiaXML.xml"));

    var xml;

    function whenLoaded(evt:Event):void {}

    xml = new XML (evt.target.data);

    var mySetsList:XMLList=xml.children();

    / / / MENU BUTTONS.

    / / POSITIONING of the BUTTONS on the INSIDE OF THE CONTAINER MENU.

    var rowMaxWidth:Number = 500;

    var totalWidth:Number;

    Var: line number;


    var cellWidthArray:Array = new Array();

    var sumCellWidthArray:Array = new Array();

    / / CREATE BUTTONS.

    for (var i: int = 0; i < mySetsList.length (); i ++) {}

    var newSetButtonMC:setButtonMC = new setButtonMC();

    //

    imageLoadArray = new Array();

    for (var j: int = 0; j < mySetsList [i].) IMAGE.length (); j++) {

    imageLoadArray [imageLoadArray.length] = mySetsList [i]. IMAGE [j]. Attribute ("smallURL");

    }

    newSetButtonMC.imageArray = imageLoadArray;

    //

    newSetButtonMC.setButtonText.text = mySetsList.attribute ("setTitle") [i];

    newSetButtonMC.setButtonText.autoSize = TextFieldAutoSize.LEFT;

    //

    cellWidthArray [cellWidthArray.length] = newSetButtonMC.setButtonText.width;

    sumCellWidthArray [sumCellWidthArray.length] = sum(cellWidthArray,0,i);

    trace(cellWidthArray[i]);

    totalWidth = sum(cellWidthArray,0,i);

    row = Math.floor (totalWidth/rowMaxWidth);


    newSetButtonMC.x = sumCellWidthArray [i] +(i*10);

    newSetButtonMC.y = (newSetButtonMC.height + 10) * rank;

    newSetButtonMC.buttonMode = true;

    newSetButtonMC.addEventListener (MouseEvent.CLICK, onClickButton);

    menuContainer.addChild (newSetButtonMC);

    }

    / / / MENU BUTTONS ACTIONS.

    function onClickButton(mevt:MouseEvent):void {}

    / / LOAD the IMAGES in the GALLERY.

    var targetButton:setButtonMC = setButtonMC (mevt.currentTarget);

    imgPos = 0;

    imgPosArray.length = 0;

    for (i = 0; i < targetButton.imageArray.length; i ++) {}

    imagesLoader = new Loader();

    imagesLoader.load (new URLRequest (targetButton.imageArray [i]));

    imagesLoader.contentLoaderInfo.addEventListener (Event.INIT, getImageWidth);

    imagesLoader.x = i 200;

    imagesContainer.addChild (imagesLoader);

    / / BIG LOAD IMAGE WHEN click ON the IMAGE OF the GALLERY.

    imagesLoader.addEventListener (MouseEvent.CLICK, loadBigImage);

    }

    }

    function getImageWidth(evt:Event):void {/ / this function get the widths of images}

    imgPos = evt.currentTarget.width;

    / / trace (imgPos);

    imgPosArray [imgPosArray.length] = imgPos;

    trace (imgPosArray);

    }

    function loadBigImage(evt:MouseEvent):void {}

    trace ("ok");

    }

    }

    Thank you very much

    Abstrato

    If one is your array of movieclips and space is white space between the end of a movieclip and the start of the next leading is the space between adjacent lines and width is the maximum width of your lines and you want your movieclips begin to startX, startY, you can use the function below to organize your movieclips:

    function arrangeMCF (a: startX:uint, startY: uint, space: uint, attack: uint, table, width: uint) {}

    var curentX:Number = startX;

    var YCourant: Number = startY;

    for (var i: uint = 0; i<>

    If (a [i] .width + currentX<>

    a [i] .x = currentX;

    a [i] there = currentY;

    currentX += [i] .width + space;

    } else {}

    currentX = startX;

    += currentY leading;

    a [i] .x = currentX;

    a [i] there = currentY;

    currentX += [i] .width + space;

    }

    }

    }

  • Position in the list of control

    Hello!

    How can I get the position of an object is in a list control? The object is in an itemRenderer.

    For the example Code to join:
    How can I get the component < mx:Text > to have the text property equal to the position in the list?

    "Francisc Romano" wrote in message
    News:gh61oq$KL$1@forums. Macromedia.com...
    > Thank you very much! :)

    http://www.magnoliamultimedia.com/Flex%5Fexamples/LineNumExample/

    HTH;

    Amy

Maybe you are looking for

  • CTRL T does not load a new tab

    When I use Ctrl-T or click on the + tab, I get an error. The address bar has the addresses of all the tabs loaded in common and of course, fails. This occurs in the user account from my work, but not in the Admin or a new Test user account. Also, if

  • Apple Mail &amp; IMAP Bell of intermittent problems of connection and synchronization

    I had Bell (Canada) mail for years and has implemented the server IMAP end of 2015 but just 2-3 weeks ago I started having problems with my iPhone and Macbook, mailboxes remaining in harmony. If I delete a message or move it to a folder, it may or ma

  • 3 beeps on startup satellite A200

    Hello I have a Satellite A200 E-530 (Core2duo T5300) began to my laptop went blank when turn on and it emits 3 beeps and a few beeps 2 times. I have check the Rams are quite good. I found that the cpu fan is not moving and turn it on and sometimes th

  • Preview does not release the PDF files in the Recycle Bin.

    After review of any PDF in preview, and then move it to the trash, the file may not be emptied from the Recycle Bin without having to restart the computer. Anyway do preview release the file without having to restart the computer?

  • Firewall Windows - have no option to turn on.

    I have Windows XP with SP3. My "windows security alerts" icon has a red top 'X'. I click on it, and the "windows Security Center" said that my firewall is turned off. I click on the "Windows Firewall" link at the bottom of the "windows security cente