problem of JavaFX and javascript

Hello

I work with Javafx and facing a problem regarding the javafx and javascript event. I use WebView of javafx and points associated with the application of the swing.
I'm passing a url and be able to view the Web page.

The Web page contains a button that has a validation. After clicking on a popup alert is supposed to be opened against this validation.

But the alert does not come.
could you please enlight on it.

Kind regards
Dev.

Note that your question belongs in the forum later and JavaFX 2.0 not 1.x forum JavaFX (JavaFX 1.x did not have a WebView).

JavaFX 2.0 and later versions «JavaFX 2.0 and later forum»

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

To get windows pop up for WebView, you must implement an appropriate Manager.
Perhaps a future version of a WebView will provide implementations by default of these dialog boxes, but there is currently no default behavior for many of these methods in JavaFX 2.2 (i.e. basically they are simply ignored).

See WebEngine methods:
setOnAlert
setPromptHandler
setConfirmHandler
setCreatePopupHandler

For your example, you probably want to predict an EventHandler setOnAlert that creates a new dialog box that contains the alert information.

For example, the following code displays a couple of alerts when the user triggers them by pressing a button html with a javascript onclick handler:

import javafx.application.Application;
import static javafx.application.Application.launch;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.layout.StackPane;
import javafx.scene.web.*;
import javafx.stage.*;

public class WebViewWithPromptHandler extends Application {
  public static void main(String[] args) { launch(args); }
  @Override public void start(final Stage primaryStage) {
    WebView webView = new WebView();
    webView.getEngine().loadContent("");
    webView.getEngine().setOnAlert(new EventHandler>() {
      @Override public void handle(WebEvent event) {
        Stage popup = new Stage();
        popup.initOwner(primaryStage);
        popup.initStyle(StageStyle.UTILITY);
        popup.initModality(Modality.WINDOW_MODAL);

        StackPane content = new StackPane();
        content.getChildren().setAll(
          new Label(event.getData())
        );
        content.setPrefSize(200, 100);

        popup.setScene(new Scene(content));
        popup.showAndWait();
      }
    });

    final Scene scene = new Scene(webView);
    primaryStage.setScene(scene);
    primaryStage.show();
  }
}

-----------

If you want to use predefined and model logic of dialogue to set your WebView dialogue management, then refer to the ControlsFX project:
http://fxexperience.com/controlsfx/

Tags: Oracle

Similar Questions

  • Problems with HTTPS and javascript widgets

    My HTTP site works fine, but when I switch to HTTPS, I get the following error...

    MuseJSAssert: Error calling the function switch: TypeError: E.split is not a function

    I have even tried to create a simple page with nothing else than a javascript widget, and I still get the error when you use the HTTPS version.

    FYI - I upload my pages using the 'upload to the FTP host.

    Muse and HTTPS is not compatible?

    It is more likely a problem with your server as a problem of cross-site script because the HTTPS protocol uses a folder or a different domain and browser security mechanisms as long as the server itself remove access to the script so. If there is a specific secure folder on the server, import is your files, otherwise, you will need to set an option in the web interface to allow HTTPs and normal HTTP access to your folder.

    Mylenium

  • JavaFX with Google Maps and JavaScript callback

    Hi all

    I wanted to create an application in javafx where use can click on the google maps map and the application will save the x - y coordinates. I found this

    Article on the experience of java fx cards in JavaFX 2.0 / / JavaFX News, demos and Insight / / FX experience and that worked very well. But this example

    does JavaFX to javascript.

    Now, I added this method to their java script:

     google.maps.event.addListener(document.map, "click", function(event) {
        var lat = event.latLng.lat();
        var lng = event.latLng.lng();
        // populate yor box/field with lat, lng
        alert("Lat=" + lat + "; Lng=" + lng);
    });
    

    and it works if I call the page html by itself. But if I click on the card inside my javafx application, no popup will appear. That, probably something with the webengine

    but I don't need the popup, I need information lat and LNG in my java fx application.

    Anyone have an idea how to realize that?

    Thank you

    Hauke

    See this section of the tutorial.

    Also, since you mentioned that the alert box has not been indicated, if you don't want this feature at some point, you can register a handler with the WebEngine onAlert.

  • NoScript installed accidentally, cannot get rid of it and JavaScript has been deactivated, even though it says that it is enabled - help!

    I accidentally installed NoScript when you try to remove the ads/pop-ups. Now it is at the origin of the problems on sites that I use regularly and I can't get rid of it. It does not appear on the Tools/Add-ons so I can disable and JavaScript has been deactivated, even though it shows as "Enabled".

    Help would be appreciated.

    It has never worked exactly as ghostery has never worked all that I get is not the extensions plugins

  • Trying to get on my email, the following statement comes from the IPU: "we're sorry, but you must enable cookies and Javascript to use your username with this site. I click on "here", but nothing happens. How to enable the amd Javascript cookies?

    Try to get t my email, this happens: we're sorry, but you must enable cookies and Javascript to use your username with this site.
    How can I do this?

    George Szántó

    [email protected]

    see similar question answered https://support.mozilla.com/questions/836913

    To be notified of updates to a question, if this is your problem or not just click on the "Get email notifications" and follow made the choice. Only the original poster can mark it as resolved, so there should be a slight difference in choice as an original poster and where you lock on another issue. Notifications only apply to individuals the question where is entered.

  • I have problems with JavaFX applications run on raspberry pi!

    I have problems with JavaFX applications run on raspberry pi. I did all the steps of the course videos: overclocking, without comment that I had to uncomment on the framebuffer, but Exceptions are always produce. Demonstration of fireworks as an example does not work. Someone went through this problem? Java applications are ok. Like the versions of java in netbeans project and also on 'Properties' and they are all JDK 8. So if anyone can give a clue, I am very grateful!

    Can you provide the exceptions that you got so I can help you better?

    You want to make a coaching for this session?

    Vinicius-

  • Problem with IMovie and Quick time

    Hey everybody,

    I am faced with an unexpected problem with Quicktime and I Movie, and I was wondering if someone had already known that:

    I want to create a film based on shots from my personal camera. I started to work with IMovie to create a sequence of opening and added his musical band. I exported the scenes in Quick Time format without any problem. However, when I merge the exported sequence of I film with shots of my video camera, the soundtrack is completely eliminated.

    I checked on the Internet and saw that there might be a problem of "Codecs". To avoid this, I exported the sequence IMovie with Codecs of same as one of my video camera files.

    Now, if I compare the files exported from I Movie and those of my video camera, they have identical characteristics. However, the soundtrack will always disappear when I merge them.

    Could someone please help me solve this problem?

    Thank you very much in advance.

    Concerning

    Could someone please help me solve this problem?

    Not only based on what you already said.

    I want to create a film based on shots from my personal camera. I started to work with IMovie to create a sequence of opening and added his musical band. I exported the scenes in Quick Time format without any problem. However, when I merge the exported sequence of I film with shots of my video camera, the soundtrack is completely eliminated.

    How would you"merge" files? (I.e. a "QuickTime" format is any form of data compatible with the platform of supply and the specific structure of QT incorporated into real employment that is stored in a container of MOV file on any of up to 99 tracks possible). Also, what app do you use for reading the file 'merged '? (For example, some media players ignore secondary audio tracks as a result of some methods of 'fusion' of files so it is important to know how the files are "merged," whether or not the audio data are "scattered" several tracks, and/or if the Media Player supports playback of multiple, sequential audio popular.)

    I checked on the Internet and saw that there might be a problem of "Codecs". To avoid this, I exported the sequence IMovie with Codecs of same as one of my video camera files.

    The specific codecs and settings using the specific version of iMovie? (The current Mac OS X operating systems have two X QT and 'classic' Qt integrated structure so it is important to know what structure is used here and how).

    Now, if I compare the files exported from I Movie and those of my video camera, they have identical characteristics. However, the soundtrack will always disappear when I merge them.

    As a general rule, you should review the file "merged" to determine why it does not play back correctly rather than comparing the characteristics of the source being merged files. The main problem here seems to be in your project workflow. That is, you seem to be when you perform an operation in two steps rather than edit several iMove multimedia files and then export the combined results in a video the video and audio tracks have been flattened and exported in standard compression formats with unified settings, features and the.

  • problem with Safari and the opening of sites

    problem with Safari and the opening of sites

    Please describe the problem in more detail?

    Try to reset the settings of Safari:

    1. open Safari

    2. click on the Safari menu at the top (to the right of the Apple logo)

    3. Select the Preferences/Privacy tab

    4. click on remove all data from the Web site

    5. close Safari.

    Remove cache Safari files:

    1. click on finder

    2. look for the menu GO to top

    3. click on GO and hold down the option key. This will show a user library folder.

    4. click library and find the Caches folder

    5. in the folder caches com.apple.Safari Ouvrezledossier

    6. move the Cache.db file Trash.

    This should solve the problem. If it does not help, try to disable the Safari extensions

    1. open Safari

    2. click on the Safari menu at the top (to the right of the Apple logo)

    3. Select Preferences

    4. find the Extensions tab

    5 disable all extensions of

    6. relaunch Safari

  • I created a new profile to resolve a problem of crash, and now I can't get to my favorites.

    Create the new profile has solved my problem of crash and I copied files and folders from my old profile to my new but I still can't have my favorites. What I am doing wrong?

    You can also restore bookmarks from a JSON backup in the folder bookmarkbackups.

  • Is anyone able to run Adobe CS5 with El Capitan now? I've read about problems with Illustrator and photoshop, but these seem to be in 2015 Octobe5. She improved at all? I need to upgrade that I am running an old OS v but I need to run CS5.

    I've read about problems with Illustrator and photoshop on EL Capitan, but these seem to be in October 2015. She improved at all? I need to upgrade that I am running an old OS v but I need to run CS5. Can not afford to go to CC. I have a Macbook Pro.

    CS5 and 10.11 are not supported and will never be supported by Adobe or Apple.

    However it works for some, more actually, but not all. There are sporadic problems with Illustrator, Photoshop seems to be the best. Do not expect an improvement and keep in mind that anyone from Adobe, Apple or anywhere else will fix it.

    Do a clean install

    Make sure you have the Apple Java

    h ttps://support.Apple.com/kb/DL1572?locale=en_US

    Make sure you have your serial number and if you are having problems with the serial number or the serialization however adobe of web server will not support your problem.

    update the application via photoshop.

  • problem with java and pogo games

    I use mozilla, and now with the problems with java and hackers cannot play my pogo, what can I do? I disabled my java I tried java 6 does not work or is not safe, what is a safe way to play games on pogo using java?

    Pogo.com is determined as a website SAFE to use Java with Mozilla Firefox?

  • I'm having a lot of problems with firefox and cannot figure out how to get help. It all started when I updated to 13. I get all kinds of advertising popups, I can't play a

    I'm having a lot of problems with firefox and cannot figure out how to get help. It all started when I updated to 13. I get all kinds of advertising popups, I can't play a game on FaceBook called Farm Town at all, and I get a popup of AVG on the cookies that I can't get rid of. These issues are causing me to use Chrome quite often, although I like Fox better. I've searched and searched how to get help and find nothing. How can I get personalized technical help? These problems will not occur in Chrome at all. Thank you.

    Do a check with some malware malware, analysis of programs on the Windows computer.

    You need to scan with all programs, because each program detects a different malicious program.

    Make sure that you update each program to get the latest version of their databases before scanning.

    Alternatively, you can write a check for an infection rootkit TDSSKiller.

    See also:

  • Problem with youtube and other video sites

    I have a problem with youtube and other video sites:

    Everything is up-to-date (flash, FF, my plug ins.) but I get crashes when loading the video. I can hear the sound but I see only the first frame of the video.

    I've reinstalled flash/firefox or tried updating them again for about 4 times now and my cookies/cache has also been errased which i usually don't do. If i enter FF's safe mode it also freezes.
    

    I hope someone can help, I looked for answers on google before and I tried everything I saw, but it did not help.

    GRTS,
    agrash

    I had the same problem, I uninstalled the plugin Flash player (Adobe Flash Player 11.0.1 152) and the problem is solved. I installed the plug-in again and the problem came back. So right now I have no flas Player liked-in, but I don't have too much problem. I hope that I will not find another problem, but it seems that everything is OK.

  • My book pro 15 Mac since April 2014 retina does not work because of problem of logicboard, and without any reason. Fact it is passed to one of you so early? Do you know something about any recall for this problem?

    My book pro 15 Mac since April 2014 retina does not work because of problem of logicboard, and without any reason.  Fact it is passed to one of you so early? Do you know something about any recall for this problem?

    There is no repair program from Apple for any 2014 Mbit/s at the moment.  Have you taken your MBP to a store for a FREE Apple genius bar?

    Ciao.

  • Pavilion Notebook PC 15-079er: problems with sleep and shutdown 15-n079er HP Pavilion Notebook PC.

    Hello world

    I have a huge problem with my Pavilion. I used Windows 8.1 earlier, and I decided to upgrade to Windows 10. I did not like something (can't remember what) and decided to return to Windows 8.1. Almost a year passed, I am again on Windows 10. But if I SLEEP my computer:

    • Screen goes black, everything seems normal.
    • No matter how long wait, fan keeps spinning and power LED, LED Wi - Fi on.
    • Keyboard input does not help. Does not meet what it is.
    • The only thing left to do - stop hard.

    And if I shut down the operating system:

    • Windows normally stops, close all applications, screen goes black.
    • Fan on, led on.

    I did not notice these problems with restarting and the hibernation.

    Two things I've done in this gap of the year:

    • Replacement screen. An old broke. Thanks to my cat...
    • Formatted the drive. I don't think it would do anything diffirent.

    So, any help would be appreciated.

    Thanks in advance,

    Kebab

    Hello

    On some machines, the pilot for 11 series IMEI has been known to cause that kind of question of the judgment, so it may be worth trying an earlier version.

    You can use the following method to install an earlier version of the driver IMEI.

    Download driver IMEI on the link below and save it in your downloads folder.

    http://ftp.HP.com/pub/SoftPaq/sp66001-66500/sp66228.exe

    Disable your wireless card (should be f12 ).

    Open your download folder and run the installer - it warns you that it is an earlier version, but simply continue.

    When finished, restart the laptop.

    If the computer shuts down correctly, turn on your wireless adapter and use the utility on the following link to prevent Windows 10 to update automatically the driver IMEI again.

    https://support.Microsoft.com/en-GB/KB/3073930

    Kind regards

    DP - K

Maybe you are looking for

  • Messages received during the date change, now stuck with them

    Hello, this is a stupid thing. I changed my date in the coming months with impatience and received messages from a friend. Now, I have these blocked as the latest messages and after I change the date back to normal, that I have to scroll up to actual

  • Ghost NI USB DAQ card readings

    Hello I have a question about the behavior of the NI USB-6218 data acquisition card.  Right now I use Labview to take several current readings of different channels to HAVE it.  I use resistors 250 ohms for each channel just as the instructions say t

  • Problem in creating several attributes XML with the same name of the attribute

    I am trying without success trying to create several attributes XML with the same name, as shown here in a Microsoft example configuration file:                         I'm calling the NewDocument GetRootElement functions and then "newelement" (appSe

  • Is short boot fail reason (error 1000-0146) Office of glitter and high cpu?

    Dell inspiron 6000. Windows xp professional sp 3. Three weeks ago, my computer started loud beep on startup and sparkle of the desktop icons. The touchpad has stopped working for a while, but most of the time which is fixed. I installed malwarebytes'

  • Black screen with cursor at Start Up

    original title: trying to fix the 2 systems with KSOD - it's really well I currently have 2 systems Dell with Vista, KSOD (black screen, move the mouse pointer). A desktop and a laptop. Both are standard Intel systems with Intel graphics card. They b