Creating objects and remove them on the mouse, click

I'm stuck with the problem of deleting objects in the scene. Here's my problem:

The mouse click, I create a circle and apply the translation.

and on the second click of mouse, I want to delete it off the coast.

So, to clear the scene, I tried,

MouseEvent {}

root.getChildren.removeAll)

create circle

}

doesn't seem to work. Any ideas. I fell on the canvas, but I don't know if I need, because animate a circle works well, but not clearing it...

The Node class has a research method that is used to find a node in the container based on an id:

import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Node;
import javafx.scene.Scene;
import javafx.scene.paint.Color;
import javafx.scene.shape.Circle;
import javafx.stage.Stage;

public class RemoveNodesFromCont extends Application {
    @Override
    public void start(Stage primaryStage) {
        final Group root = new Group();
        Scene scene = new Scene(root, 400, 350, Color.AQUA);
        scene.setOnMouseClicked(event -> {
            Node n = root.lookup("#myCircle");
            if (n == null) {
                Circle circle = new Circle(event.getX(), event.getY(), 50, Color.BLUE);
                circle.setId("myCircle");
                root.getChildren().add(circle);
                System.out.println("The circle is created");
            } else {
                root.getChildren().remove(n);
                System.out.println("The circle is removed");
            }
        }
        );
        primaryStage.setScene(scene);
        primaryStage.show();
    }

    public static void main(String[] args) {
        launch(args);
    }
}

Tags: Java

Similar Questions

  • Captivate 9 record and no blades on the mouse, click on when entering on extended screen

    Hi, my main computer is a laptop and I have two external displays connected through a docking station. When the Captivate 9 capture window isn't that I appointed as my main screen on the monitor, it will capture all the slides, or capture specific positions click. Has anyone experience this problem? Solutions other than changing my settings on the computer whenever I need to record a video of training? Thank you.

    Yes, it's a known problem that occurs in certain situations with certain systems, video drivers or software applications.

    Update video drivers does not resolve the problem, you may simply use your current solution.

  • My iPhone and Mac all have two Photos related to iCloud, same images appear on both. How to remove pictures from the phone without removing them from the Mac

    I've shared pictures between my Mac and iPhone using iCloud. Recently downloaded about 1800 brother SmugMug account family photos. Subsequently discovered that they had all been loaded on my phone as well. When I try to delete them from my phone, I get a message the suggests that if I do, the photos will be removed from my Mac was fine. How can I remove the phone and let the Mac intact?

    I've shared pictures between my Mac and iPhone using iCloud.

    What iCloudService do you use?

    • If the iPhone and the Mac are synchronized with iCloud photo library, removal of the photos from the iPhone will remove them from the Mac as well.  iCloud photo library is a synchronization service that will ensure that you see the same pictures on all devices. All change at will the timing and any deletion or any import.  To win the storage on the iPhone allow the iCloud Photos setting "Optimize Storage.
    • If photos have been synced with my photos and not iCloud library stream, you can remove them from the iPhone. They must stay in the library on your Mac. But before a massive deletion on any device, make a backup of your photo library, just to be sure.
  • I want to open two different pdf documents and view them at the same time so I can read about everything by watching the other document.  I use Acrobat DC and whenever I open a document it creates a tab and I can only examine a document at a time.

    I want to open two different pdf documents and view them at the same time so I can read a whole watching the other document.  I use Acrobat DC and whenever I open a document, it creates a tab and I can only examine a document at a time. Is it possible to display two or more documents without having to toggle tabs?

    Don't think that will work, but you can drag the tab to a new window. Each window can have a set of tabs.

  • I want to create a Web site where people can choose a date and time and click on search, and it will find the photo of my HARD drive and show them on the page, is that poosible? If so could somone tell me how I will pay?

    I want to create a Web site where people can choose a date and time and click on search, and it will find the photo of my HARD drive and show them on the page, is that poosible? If so could somone tell me how I will pay?

    On your local HARD drive? N ° on your web server? Course

    How do you know php? There are exif function that can read EXIF headers on your images. You can use it in conjunction with the functions of file system scanning of the images on your web server. If you have thousands of images, you want to index the results in a database rather than search the real-time file system.

  • I've got 4 Lightroom and my hard drive is too full with photos I have in lightroom. I want to move a lot to a USB key and remove them from lightroom. What are the steps to do this please?

    I've got 4 Lightroom and my hard drive is too full with photos I have in lightroom. I want to move a lot to a USB key and remove them from lightroom. What are the steps to do this please?

    I have some listed here videos that will help you with this

    Organization of Lightroom - Lightroom and Photoshop training

    Dave

  • How to remove programs from the system tray without removing them from the startup?

    How to remove programs from the system tray without removing them from the startup on Windows XP folder?

    Hello

    The first step is to identify the program that represents the icon and decide whether it should be in the system tray (most are not necessary). Hold the cursor of the mouse on the icon to see the name of the program that launches the icon.

    The best bet is to click the icon to see if this opens the box of the program options. If so, look for a selection similar to "remove from the system tray.

    Alternatively, you can hide the icons in the system tray.

    Here's how:

    1. right click on the taskbar and select "Properties".

    2. in the "Notification area" click "Hide inactive icons" if she already unchecked and then click on the button "Customize".

    3. click on the ' column next to each of your current behavior and choose one of the three behaviors for each program icon that appears in the system tray: "Hide when it is idle," "Always hide", or "always show".»

    If you hide an icon, but then see it again the next time that you log on to Windows, you may need to uninstall the program to permanently remove the icon. Uninstall the program permanently removes the program from your computer. For more information, see Uninstall or change a program.

  • Open submenus when I stop on them with the mouse pointer does not work

    I used to use Vista Upgrade of XP until it hit the big time. With this installation, the option 'Open submenus when I dwell on them with the mouse pointer' worked perfectly well.  Since I did a format and installed the full installation of Vista version, and now this feature does not work. I checked and re-checked the option in the customization of the menu star and nothing. Also unable to find what anyone at the mouse settings itself.

    Does anyone know how to get this feature to work again once it's something I use a lot.

    Concerning

    Owen

    Hello

    If none of these help or you find a solution please report.

    Does work here on Vista either, but I don't want it works even if it is checked.

    Try UnChecking the start - Customize - Menu tab apply / OK and then go back and save
    Apply / OK.

    If no joy this initiative will eventually.

    Follow these steps to remove corruption and missing/damaged file system repair or replacement.

    Run DiskCleanup - start - all programs - Accessories - System Tools - Disk Cleanup

    Start - type in the search box - find command top - RIGHT CLICK – RUN AS ADMIN

    sfc/scannow

    How to analyze the log file entries that the Microsoft Windows Resource Checker (SFC.exe) program
    generates in Windows Vista cbs.log
    http://support.Microsoft.com/kb/928228

    Then, run checkdisk - schedule it to run at next boot, then apply OK your way out, then restart.

    How to run the check disk at startup in Vista
    http://www.Vistax64.com/tutorials/67612-check-disk-Chkdsk.html

    ------------------------------------------------

    Maybe something here: [check Control Panel - mouse or TouchPad (as applicable)]

    If a mouse (or if you use a touch screen and a mouse)

    Start - computer, or Windows Explorer - Tools - Folder Options - general tab - check the
    Single click to open an item - APPLY / OK

    Control Panel - mouse - look for hover or click Automatic similar settings according to your mouse.

    When a TouchPad

    Look in the Notification area next to the clock for all TouchPad control program.

    Control Panel - mouse - also look for it TouchPad (mine is on the device however settings tab
    other brands and maybe on the other tabs and more than one). There are usually the parameters that
    can determine if a click, double click, hover or can open or close a program.

    Start - computer, or Windows Explorer - Tools - Folder Options - general tab - check the
    Single click to open an item - APPLY / OK

    If some people are well positioned can change to some other setting if you plan to leave
    them that way and then change again.

    I hope this helps.

    Rob Brown - MS MVP - Windows Desktop Experience: Bike - Mark Twain said it right.

  • I moved the documents in the wrong files can I go out and drop them in the correct file

    I did a daily newspaper and accidentally creates a different file for each month but penetrated some day diarys bad monthly files. How can I remove them and move them to the right file

    The use of the words 'documents' and 'files', I may need more information.  A document (for example you can create with a text editor) is a file.  The various documents (files) are stored in folders (icon for them looks like a folder of files in an office filing system).

    If you have saved a file (document) in a wrong folder, you can go using Windows Explorer (generally you press start and then select "Documents" in the list on the right above the Start button) and navigate to the folder where the file is.  Once you've found the file you can right-click on it and select "Cut" (or "Copy" If you want to be sure), then move them to the folder where you want the file and right click in an empty area in this folder and select "Paste".  (If you used the copy rather than the option of cutting option, you will then have to go back and delete the file in its original location).

    Another way to do the same thing that can be easier would be to open start > Documents and navigate to the folder where the wrong file and then open a second window by clicking Start > Documents again (a second window will not open unless you have navigated to a different location from the location of the opening in the first window).  In the second window, navigate to where you want the file to be.  With two windows open just click and drag the file from where it is in the first window to where you want it to be in the second window.

    If you really did not on folders, please answer with what application (program), you used to create the diary.

  • keep the photos in icloud, but remove them from the iOS device?

    Hi, need help to keep my old photos in the cloud, then to remove them from my iphone device. I can also keep on my mac but still once, how can I make sure that when I delete from my iphone I can still access them in the cloud or on my big Mac? My phone is getting to the maximum it can hold up to now need to move them to a storage for later viewing device, editing or other.

    Thank you

    You cannot store pictures on iCloud and remove them from your device. Remove them on the phone also icloud removes them. You can set for storage optimized on your device that compresses the resolution of the device stored photos, keep the originals in iCloud.

    If you want to be able to todelete pictures from your phone and store them elsewhere, you must use subscription such as Dropbox cloud storage or store them on your computer.

    iOS: import personal pictures and videos of iOS devices to your computer

  • How to find corrupted files and remove them on mac i

    How to find corrupted files and remove them on i mac?  AM currently using OS x EL capitan 10.11.12 Mac said to run slowly and the recent upload did not work until the 3rd attempt.

    Thank you

    You do not have.

    You can run this program and post the results so that we can see what you have installed that could cause your problems.

    http://www.etresoft.com/etrecheck

  • Is there a way to copy the drivers and setup of the drive from the computer and transfer them to the reader of the dead computer?

    Separated from this thread.

    Is there a way to copy the drivers and setup of the drive from the computer and transfer them to the reader of the dead computer?

    Hello

    You cannot copy the drivers installed anyway.

    Saving your files:

    You can remove the hard drive and put it in a hard drive USB enclosure > plug it into another computer > and try to read and copy your data in this way.

    See you soon.

  • Reconnect before proceeding... (No, just remove them from the catalog)

    I met the 'Media files have been moved because they were imported in your catalogue' and I get the search never ends for them.  How can I tell PE just remove them from the catalog?  I deleted these files by accident, but it's normal.  Rather than offer me the possibility to remove them and move on, PE seeks constantly over my hard drives and show up with the same list, he always does.  Just remove them and don't ask me no more!  How to spend it?

    WSC3 wrote:

    I met the 'Media files have been moved because they were imported in your catalogue' and I get the search never ends for them.  How can I tell PE just remove them from the catalog?  I deleted these files by accident, but it's normal.  Rather than offer me the possibility to remove them and move on, PE seeks constantly over my hard drives and show up with the same list, he always does.  Just remove them and don't ask me no more!  How to spend it?

    I prefer not to keep the default choice of automatic search for the missing files. Open the Edit menu > preferences > files and uncheck this option. You will be free to begin a search, when necessary.

    Then use the file menu 'reconnect all missing files. You get a list of missing files in the window closing. In the middle of the second line, you have a small icon to open a menu in which:

    -You can choose all

    - then delete all.

  • How to transform a layer object and a path at the same time?

    Hi all

    I know that I will start when you tell me the answer to this!

    I would really like to know if there is a way I can manage to transform a layer object and a path at the same time... or if there is no work around to get there.

    In a Word, for example I spend a VERY long time to create a drive complex around a very detailed object and then at the end note to what twisted and perspective, and would like to straighten.

    Of course I could turn and correct the object and then carefully turn the path - but it will not correct and I have to spend a lot of time the path of adjustment and make SURE, it is perfect.

    Are there not somehow, I was able to transform set?

    Usually, of course, I do all the correction to straighten and correct the perspective in advance, but in some cases after I am done creating the path I then notice that image could have used other adjustments.

    I appreciate all the advice you can get :)

    Thank you kindly,

    Christine

    Transform the layer and then target the way and make "Edit > Transform path > Again. If you make several changes on the layer, and then each time that validate you and leave transformation mode, remember to do the ' transform path > Again "to keep the layer and the synchronized pathname.

  • AS2 help, moving object to the mouse, click.

    Here is the code that I have, I know that these are the basic elements of wihc I need to use it, they work individually, but together they are not

    on {(press)
    this.startDrag ();
    }

    on (release) {}
    stopDrag();
    }
    }

    This += ._y this ._ymouse/4;
    This ._x += this ._xmouse/4;


    So what I try to do is to get the object to move more slowly than the mouse, but finish moving all over the place where I let go the click. So far, I can get the object to be moved with the mouse without clicking and dragging at a slow speed, but I can't get the drag to work at a slower speed, he moves as soon as the mouse moves. Can someone help me? Very much appreciated.

    {this.onMouseDown = function ()}

    {this.onEnterFrame = function ()}

    YourObject._x =. 5 * yourobject._x +. 5 * _xmouse;

    YourObject._y =. 5 * yourobject._y +. 5 * _ymouse;

    If (Math.ABS(YourObject._x-_xmouse)<><>

    delete this.onEnterFrame;

    }

    }

    }

Maybe you are looking for

  • Create a theme that, when selected, open multiple slides

    I can create a theme using Keynote 6.6.2-no problem. I can record on the theme selector, no problem. However, I would like to create a theme, which, when it is selected in the theme selector, open several slides prepared in advance, not only the titl

  • Charger stopped working randomly

    Hello I used my charger this morning and everything was fine, I went to plug my phone tonight and nothing has changed, it will not work! What can I do - annoyed as I rely on my phone a lot.

  • Cannot view images as thumbnails in my photos

    HP Pavilion dv6 laptop with windows 7.  I can only get the icons on the screen and click on each one to display my photos in the library, my photos.   Can someone help please to be able to see all my photos in thumbnails on the screen?

  • Variable width profiles do not apply

    Jumped into illustrator this morning to simple line drawings. Made sure to uncheck new art has basic appearance. I have change the width of the stroke to any random value, choose a profile of variable width and draw. Profile width never changes. I ju

  • Anyway is to better organize the fonts within the PS CS6?

    I'm looking for a way to either; [A] person to create "folders of fonts" which would contain any number of fonts by file, which would in turn appears under the police drop. Is or [B] assuming that it does not work, another way to organize fonts in PS