Check if there's internet connection

Having problems with building or using the JCEF Java binding? Ask your questions here.

Check if there's internet connection

Postby Rumpelstiltskin » Wed Nov 16, 2016 7:01 am

Hi everyone,

I am new with JCEF (acutally new to Java too) but I am learning about it. I am doing a project on Eclipse Neon and I wish you could help me on these following two question.

1. Is it possible to check if the project can connect to a website name or ping a specific IP address? I prefer a project to do something when it can't connect to my website.

2. How can I send "System.out.println("test");" to Eclipse's console window from a webpage by using Javasacript?

Thank you very much in advance
Rumpelstiltskin
Newbie
 
Posts: 2
Joined: Wed Nov 16, 2016 6:38 am

Re: Check if there's internet connection

Postby magreenblatt » Wed Nov 16, 2016 1:17 pm

For #1 see comments at the end of https://bitbucket.org/chromiumembedded/ ... resolution. For #2 you can use console.log() from JavaScript and then implement CefDisplayHandler.onConsoleMessage to call System.out.println().
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: Check if there's internet connection

Postby Rumpelstiltskin » Sat Nov 19, 2016 8:10 pm

magreenblatt wrote:For #1 see comments at the end of https://bitbucket.org/chromiumembedded/ ... resolution. For #2 you can use console.log() from JavaScript and then implement CefDisplayHandler.onConsoleMessage to call System.out.println().


Thank you so so much magreenblatt. I have made it through!

Beside, I put an alert to confirm exit before frame.dispose();


Code: Select all

int confirmed = JOptionPane.showConfirmDialog(null,
        "Are you sure you want to exit the program?", "Exit",
        JOptionPane.YES_NO_OPTION);

    if (confirmed == JOptionPane.YES_OPTION) {
      CefApp.getInstance().dispose();
      frame.dispose();
    }




but the frame always get freeze. How do you make a confirmation alert before exit?
Rumpelstiltskin
Newbie
 
Posts: 2
Joined: Wed Nov 16, 2016 6:38 am


Return to JCEF Forum

Who is online

Users browsing this forum: No registered users and 7 guests