OnAlert for WebView inside JFXPanel

I am trying to implement "alert" functionality in a webview that is inside a JFXPanel. Alerts need to be blocking, therefore I need to be able to block inside the onAlert event handler while I display the alert dialog to the user, then proceed after the user clicks OK.
I am getting either deadlocks or crashes - but haven't found a successful strategy.
Creating a modal dialog using a Java FX Stage (showAndWait()) causes a crash as soon as the dialog is closed. This is apparently because the top level window is an AWT/Swing window and not a JavaFX window, so it pukes.
Attempting to create a modal dialog with Swing just deadlocks the system because (I presume) I have to wait inside the event handler for the swing thread to complete, but Swing needs to interact with the JavaFX thread in the mean time, which causes the deadlock.
Any ideas how I can create a blocking alert box for a WebView inside a JFXPanel?
-Steve

Thanks for the reply.
ArtemAnaniev wrote:
Could you provide a crash log (hs_err_*.log), when it crashes with JavaFX stage, please?Unfortunately I don't have the error logs anymore.... wasn't able to get it working and just put it on hold. I just tried to set up a small example to reproduce, but now it seems to be working (in my simple example) with showAndWait(). The crash was happening in a more complex example that I don't have handy right now, so it is likely that there were other factors in the deadlocking.
>
As for using Swing to implement onAlert() and similar callbacks, it should be possible. You can't just call SwingUtilities.invokeAndWait() as it indeed would lock FX thread. Instead, you need to run a nested FX event loop. Wait... it's not in JavaFX public API, unfortunately :(Ahh.. that will be a very nice feature... I was looking all over for something like it.
>
Have you tried Stage.showAndWait()? Is it the method that causes the crash?Yes. That is the method that was crashing. The window would open, but it would crash as soon as I closed it. As I mentioned above, I can't seem to reproduce it right now with my simple example.. Will post here when I am able to reproduce.
-Steve

Similar Messages

  • WebView inside JFXPanel: No drag and drop events received

    Hi,
    I'd like to manage Dnd between apps and a Swing application with a JFXPanel which embeds a WebView component.
    Currently, all drops are forbidden on top of the WebView, and I'd like to find a way for the WebView to accept transferable object such as URL...
    Moreover, code like this does not display anything in console. If I create a native JFX application (without JFXPanel Swing layer) the drag events occur.
                    webView.setOnDragDetected(new EventHandler<MouseEvent>() {
                   public void handle(MouseEvent event) {
                        System.err.println(event.toString());
              webView.setOnDragEntered(new EventHandler<DragEvent>() {
                   public void handle(DragEvent event) {
                        System.err.println(event.toString());
              webView.setOnDragOver(new EventHandler<DragEvent>() {
                   @Override
                   public void handle(DragEvent event) {
                        System.err.println(event.toString());                    
              webView.setOnDragDropped(new EventHandler<DragEvent>() {
                   @Override
                   public void handle(DragEvent event) {
                        System.err.println(event.toString());                    
              });I guess JFXPanel catches events, or I missed something...
    If anyone could help, thanks in advance!

    Hi,
    For people who can help, here is the entire code to reproduce the problem.
    JFXPanel seems to consume the DND event, and the JFX WebView component does not receive anything.
    Thanks a lot.
    import java.awt.Dimension;
    import javafx.application.Platform;
    import javafx.embed.swing.JFXPanel;
    import javafx.event.EventHandler;
    import javafx.scene.Scene;
    import javafx.scene.input.DragEvent;
    import javafx.scene.input.Dragboard;
    import javafx.scene.input.TransferMode;
    import javafx.scene.paint.Color;
    import javafx.scene.web.WebView;
    import javax.swing.JFrame;
    import javax.swing.SwingUtilities;
    public class WebViewInJFXPanel {
         private void initAndShowGUI() {
              // This method is invoked on Swing thread
              JFrame frame = new JFrame("WebView in JFXPanel");
              frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              final JFXPanel fxPanel = new JFXPanel();
              fxPanel.setOpaque(false);
              fxPanel.setPreferredSize(new Dimension(800,600));
              frame.add(fxPanel);
              frame.pack();
              frame.setVisible(true);
              // Init JFX
              Platform.runLater(new Runnable() {
                   @Override
                   public void run() {
                        initFX(fxPanel);
         private void initFX(JFXPanel fxPanel) {
              // This method is invoked on JavaFX thread
              WebView webView = new WebView();
              webView.getEngine().load("http://javafx.com");
              // The following triggers are never invoked once in a JFXPanel
              webView.setOnDragEntered(new EventHandler<DragEvent>() {
                   public void handle(DragEvent event) {
                        System.err.println(event.toString());
              webView.setOnDragOver(new EventHandler<DragEvent>() {
                   @Override
                   public void handle(DragEvent event) {
                        System.err.println(event.toString());
                        Dragboard db = event.getDragboard();
                        if (db.hasString()) {
                             event.acceptTransferModes(TransferMode.COPY_OR_MOVE);
                        event.consume();
              webView.setOnDragDropped(new EventHandler<DragEvent>() {
                   @Override
                   public void handle(DragEvent event) {
                        System.err.println(event.toString());          
                        Dragboard db = event.getDragboard();
                        boolean success = false;
                        if (db.hasString()) {
                             System.out.println("Dropped: " + db.getString());
                             success = true;
                        event.setDropCompleted(success);
                        event.consume();
              Scene scene = new Scene(webView, 800, 650, Color.BLACK);
              scene.setFill(Color.BLACK);
              fxPanel.setScene(scene);
         public static void main(String[] args) {
              SwingUtilities.invokeLater(new Runnable() {
                   @Override
                   public void run() {
                        new WebViewInJFXPanel().initAndShowGUI();
    }

  • I have a for loop inside of while loop.when i press stop for while loop, i also would like to stop for loop.how can i solve this problem?thanks

    i have a for loop inside of while loop.when i press stop for while loop, i also would like to stop for loop.how can i solve this problem?thanks

    Hi fais,
    Following through with what JB suggested. The steps involved in replacing the inner for loop with a while loop are outlined below.
    You can replace the inner for loop with a while by doing the following.
    1) Right-click of the for loop and select "Repalce" then navigate to the "while loop".
    2) Make sure the tunnels you where indexing on with the for loop are still indexing.
    3) Drop an "array size" node on your diagram. Wire the array that determines the number of iterations your for loop executes into this "array size".
    4) Wire the output of the array size into the new while loop.
    5) Set the condition terminal to "stop if true".
    6)Drop an "OR" gate inside the while loop and wire its output to the while loops condition terminal.
    7) C
    reate a local of the boolean "stop" button, and wire it into one of the inputs of your OR gate. This will allow you to stop the inner loop.
    8) Drop a "less than" node inside the inner while loop.
    9) Wire your iteration count into the bottom input of the "less than".
    10) Wire the count (see step 4 above) into the top input of the less than. This will stop the inner loop when ever the inner loop has processed the last element of your array.
    Provided I have not mixed up my tops and bottoms this should accomplish the replacement.
    I will let others explain how to takle this task using the "case solution".
    Ben
    Ben Rayner
    I am currently active on.. MainStream Preppers
    Rayner's Ridge is under construction

  • UCCE 7.5.6 Supported Browsers for Webview and Agent reskilling

    Hi,  Can anyone out there please give me a link to the supported browsers (IE, FireFox etc) and their versions for UCCE 7.5(6) - We currently run with WIndows XP clients on IE7, however, would like to migrate to WIndows7 with IE8 / IE9
    Thanks in anticipation,
    gmb

    Below browser versions are supported and mentioned in the BOM for ICM 7.5
    http://www.cisco.com/en/US/docs/voice_ip_comm/cust_contact/contact_center/icm_enterprise/icm_enterprise_7_5/user/guide/icm75bom.pdf
    Check additional requirements for WebView Clients pg 44
    Internet Explorer 6.0 (SP1 or greater)
    Internet Explorer 7.0
    Internet Explorer 8.0 for ICM 7.5(7) or later
    Hope this helps.
    Shirish

  • Using internal SSL Certs for Webview and Reskill (ICM 7.2.X)

    Hi,
    I would like to use corporate ssl certs for webview and reskill to avoid the user having to install the self signed certificate on the local machine. Has anyone any experience of this? Can it cause any unforseen problems?
    My plan for webview is to create the certificate request in IIS for the default website, use this csr to generate the cert, then complete it by uploading the certificate.
    For reskilling, I will assume I will have to do some command line stuff here ...
    eg: keytool -genkey -keyalg RSA -keystore hostname.key
    to create the key,
    keytool -certreq -keyalg RSA -keystore hostname.key -file hostname.csr
    to create the csr, and
    keytool -import -trustcacerts -alias tomcat -file hostname.cer -keystore hostname.key
    to import the new cert
    Suggestions or comments for anyone who has tried this before would be appreciated.
    Regards,
    Brian

    I've never done it on a version so old, but at the end of the day it's just IIS and Tomcat and importing an SSL cert is very standard.
    david

  • How do I break a for loop (inside) and a while loop (outside) at the same time by a control button

    I have a while loop (outside) and a for loop (inside) and a control button within the for loop.  I want to stop the program by click the botton without finishing the for loop.  How can I do that?
    Thank you in advance.

    HI Please find attached snapshot Regards, Santosh
    Message Edited by SanRac on 12-17-2009 05:12 AM
    Message Edited by SanRac on 12-17-2009 05:13 AM
    Attachments:
    Snap1.png ‏4 KB

  • I hired a commercial artist to create a color image for the cover of a self published book. I want a black and white image for the inside. The commercial artist has not responded to this request. How do I determine the format of the color image, I'm guess

    I hired a commercial artist to create a color image for the cover of a self published book. I want a black and white image for the inside. The commercial artist has not responded to this request. How do I determine the format of the color image, I'm guessing it's Illustrator's formatting but I don't know. How can I find out if Illustrator will open the file and allow alterations? The image opens only in Apple's Pages software?

    rons,
    It seems that all you have is a raster image, presumable PNG24 or JPEG, in RGB.
    It may have been created as raster artwork in Photoshop, or it may have been created as vector artwork with the help of Illy, or as a mixture of vector and raster artwork in either application, or both combined.
    If you just need to have a raster representation in black and white based on the current colour image, you may try this, in a new RGB document (View>Smart Guides are your friends):
    1) File>Place the image (you may tick Link or untick and have it embedded);
    2) Create a rectangle with black fill (R = G = B = 0), at least as large as the image, and place it behind the image (you may ClickDrag with the Rectangle Tool between opposite corners, then Ctrl/Cmd+X+B);
    3) Select all and in the Transparnecy palette flyout click Make Opacity Mask with both Clip and Invert Mask ticked.

  • How to wrap an existing javabean for using inside a form

    I have an existing java bean(meterbar.jar) I would like to try and intergrate into a bean area of a form.
    I have looked at a bunch of documentation but am still lost. How can I use jdeveloper to "wrap" the bean for use
    inside a form. I am in totally new territory all around so please be specific. Thanks in advance.
    Linda

    I have an existing java bean(meterbar.jar) I would like to try and intergrate into a bean area of a form.
    I have looked at a bunch of documentation but am still lost. How can I use jdeveloper to "wrap" the bean for use
    inside a form. I am in totally new territory all around so please be specific. Thanks in advance.
    Linda

  • HT203167 I have purchased Forbes magazine thru zinio app. My money was deducted but I am not getting the magazine for download inside zinio app. How can I get this fixed?

    I have purchased Forbes magazine annual subscription
    thru zinio app. My money was deducted but I am not getting the magazine for download inside zinio app. How can I get this fixed?

    This forum is for questions from those managing sites on iTunes U, Apple's service for colleges and universities to post educational material in the iTunes Store. You'll be most likely to get help with this issue if you ask in the general iTunes forums.
    Regards.

  • JNDI Lookup code for EntityMananger  inside SessionBean

    Hi ,
    I am using JNDI look up inside my stateless session Bean for Thread Safety issues .
    That is
    @PersistenceContext(Unitname="someunit" name= "somename")
    Context ctx = new InitialContext();
    EntityManager em = (EntityManager)ctx.lookup("somename")Now i am having 4 methods for (CRUD) inside my sessionBean
    Do i need to use this lookup code inside my every method that is in all my 4 methods
    Please tell me this if i am having four methods inside my Session Bean do i need to do lookup inside each of my method.

    Thread safety issues? So you are saying that you actually had them, or you are assuming they will happen?
    Because I have written multiple applications that simply inject an instance of the entity manager into the EJB and I have never had any problems. The whole idea of dependency injection is to minimize the need for manual JNDI lookups; why are you trying to swim against the current?

  • How to search for speech inside premiere once I have analyzed speech without adobe story

    Is there a way to find text speech inside the metadata speech analysis window?
    Thank you.

    Thanks! This is very good. The assumption for this work flow is that you already have a word-perfect transcript file (my case - this makes the AME voice-to-text engine FAR more accurate, because it only has to find word timings - less deciphering of words. I used this workflow to produce a valid .srt file for use elsewhere. For work inside PrProCC, it is indeed the missing bridge between speech recognition and caption editing.
    Captiontube seemed promising, in that it is supposed to accept an ordinary .txt file as the transcript, but I could not get it to accept any movie URLs I entered. If you do NOT have a literal transcript to start with, then the speech recognition in Camtasia Studio 8 (uses the Windows speech recognition engine, I think) is about the same (in)accuracy as AME.

  • For loop inside  a while loop, what order is that in big o??

    If say I have a for loop inside a while loop, then is that suppose to be in the order of O(n^2) right?? Is there any possibilities to change this into the order of O(n)??

    the other size and the temp size is abstact, which can be defined. This is actually for my union method, my teacher asks me to write this method using the order of O(n) which I think it is not possible. What do you guys think??
    Below is the code I have made:
    public Set<E> union(Set<E> other) {
              int count = 0;
              Iterator<E> iterator1 = other.iterator();
              while (iterator1.hasNext())
                   count++;
              Object[] temp = new Object [data.length+count];
              n = data.length+count;
              for (int i = 0; i<count; i++)
                   temp[i] = data;
              for (int j = count; j<temp.length; j++)
                   temp[j] = iterator1.next();
              data = temp;
              return null;
    but it still has same elements on it and I am thinking of a way on how to remove those same elements

  • Simple example - Break FOR loop inside an event structure based on Front panel event change.

    I am running a for loop inside a state machine architecture that contains a FOR loop. How can I break this For loop based on Event change in front panel ??
    Abhilash S Nair
    Research Assistant @ Photonic Devices and Systems lab
    [ LabView professional Development System - Version 11.0 - 32-bit ]
    LabView Gear:
    1. NI PXI-7951R & NI 5761
    2. The Imaging Source USB 3.0 monochrome camera with trigger : DMK 23UM021
    OPERATING SYSTEM - [ MS windows 7 Home Premium 64-bit SP-1 ]
    CPU - [Intel Core i7-2600 CPU @ 3.40Ghz ]
    MEMORY - [ 16.0 GB RAM ]
    GPU - [ NVIDIA GeForce GT 530 ]
    Attachments:
    Case inside Event 3.vi ‏19 KB
    Case inside Event.ctl ‏6 KB
    Case inside Event 2.ctl ‏6 KB

    Okay. Accpeting that the design is not favorable and not advantageous when my program expands. I have begin to follow producer/consumer programming architecture.
    Please find the attached program which is a simple producer consumer with event structure. I wonder how could I stop looping around the producer and consumer loops over and over again. I am pretty sure that this ENQUEUE ELEMENT loops back to the consumer loop and starts from begining.
    I hope my first program in PC architecture with State machine and Event structure is correct. 
    Abhilash S Nair
    Research Assistant @ Photonic Devices and Systems lab
    [ LabView professional Development System - Version 11.0 - 32-bit ]
    LabView Gear:
    1. NI PXI-7951R & NI 5761
    2. The Imaging Source USB 3.0 monochrome camera with trigger : DMK 23UM021
    OPERATING SYSTEM - [ MS windows 7 Home Premium 64-bit SP-1 ]
    CPU - [Intel Core i7-2600 CPU @ 3.40Ghz ]
    MEMORY - [ 16.0 GB RAM ]
    GPU - [ NVIDIA GeForce GT 530 ]
    Attachments:
    Case inside Event 3.3-ProducerConsumer Event.vi ‏25 KB
    Case inside Event.ctl ‏6 KB

  • NAT for global inside/outside

    Hi,
    How do i specify port range for global inside or outside address?
    amdcent

    Which Cisco wireless product are you trying to configure NAT with?
    This might be useful to you: http://www.cisco.com/warp/public/cc/pd/iosw/ioft/iofwft/prodlit/iosnt_qp.htm

  • Run for loop inside event node

    Hi all, 
              We want to run for loop inside event node with 50ms delay. But when i am doing it the Labview is crashing. Please let me know if somebody did this.
    Thanks in advance,
    Regards,
    Harish. G
    Thanks & Regards,
    Harish. G.

    harishg92 wrote:
    Hi all, 
              We want to run for loop inside event node with 50ms delay. But when i am doing it the Labview is crashing. Please let me know if somebody did this.
    Thanks in advance,
    Regards,
    Harish. G
    You're implementing a For loop inside an event structure? (I don't know of any event "node" in which you can run a For loop)
    If so, that's a bad idea because LabVIEW won't be able to process any events while waiting for your For loop to get done, which might be why its crashing.
    There are tricks to accomplishing what you're trying to do without putting any for loops inside event structure. See what I have  attached and if it helps. "N" is number of times you run your For loop, timeout is whatever delay you want in each loop. This can be done in many ways without adding delays in events, another way could be to fire a separate subVI using Asynchronous call (without waiting for the VI to finish) during those delays, just make sure that such subVI finishes processing within your allocated time (that's how I'd ideally implement things). That method is better because you're doing minimal work inside events structure while using wait period wisely in a separate/parallel process.
    I hope that I understood you correctly and did not go off on a tangent.
    -BTC
    New Controls & Indicators made using vector graphics & animations? Click below for Pebbles UI
    Attachments:
    ForLoop inside Event Structure.vi ‏11 KB

Maybe you are looking for

  • New HP Pavilion 11t-n000x3​60 will not print on Deskjet f4180 printer

    The  new Laptop recognizes the printer but will not print.  No problem printing from PC s5120f . I am strictly a user, not very tech savy.

  • Embedding Fonts in PostScript and/or PDF

    Under 10.3 the Print dialogue had a Save As File option which allowed the embedding of fonts in PostScript. Choices were All, All but Standard 13 and such. This made sure that the PostScript (and generated PDF) files would render properly on systems

  • Error in posting document in FPE1

    Hi Gurus,   I tried to post a document in FPE1 and it returned an error " Manual postings not permitted". Can anyone please help me finish the posting. Points awarded for all useful solutions. Thanks Santosh

  • How do I get my two iPads to FaceTime between each other?

    After I bought my second iPad I 'registered' it under my existing ID.  I can't seem to get FaceTime to work between the two iPads. I can't get FactTime set-up on the second iPad because it wants to change my ID. Do I need to change my ID and if so, h

  • Adobe form not saving data.

    hi Experts, I am facing strange problems with Adobe forms. I am working on both Offline and online adobe forms. adobe form which i make does not allow to save data. I am using the Adobe liveCycle designer 7.1. The Adobe reader version is 7.08 and ser