JCEF reloading of browser instances

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

JCEF reloading of browser instances

Postby ramyakrishnan » Wed Sep 23, 2015 8:32 am

Hi ,

I did not find a related question to this on the forum so I wanted to ask this. As a continuation to this topic : http://www.magpcss.org/ceforum/viewtopic.php?f=17&t=13433 . I am trying to close and reload a browser whenever I have a button click performed on the menu item of my JFrame. My browser currently resides on my JPanel. I tried to do browser.close() [in my menuitem button click actionlistener method] and also browser.reload [the same way] but the browser just freezes and I couldnt do much other than forcibly stopping my application and restarting again. Is it possible to do this? Or am I missing something ? I looked into the examples in the https://bitbucket.org/chromiumembedded/java-cef/src/8e7fc7e3d4934ffbb7c080c129b264e6db963ea9/java/tests/?at=master but I could not find anything related to what I am trying to achieve. Could someone point me to any reference material or give me a brief understanding of where I am going wrong?
ramyakrishnan
Mentor
 
Posts: 62
Joined: Wed Sep 16, 2015 12:21 pm

Re: JCEF reloading of browser instances

Postby ramyakrishnan » Wed Sep 23, 2015 4:48 pm

anyone cld u help me on this ?
ramyakrishnan
Mentor
 
Posts: 62
Joined: Wed Sep 16, 2015 12:21 pm

Re: JCEF reloading of browser instances

Postby magreenblatt » Thu Sep 24, 2015 2:29 am

ramyakrishnan wrote:I am trying to close and reload a browser whenever I have a button click performed on the menu item of my JFrame

What exactly are you trying to do? If you close the browser then you will need to create a new one via createBrowser.
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: JCEF reloading of browser instances

Postby ramyakrishnan » Thu Sep 24, 2015 7:33 am

I am trying to have a "close"option as one of my menuItem and trying to get the browser to shutdown and when i click the "open browser" option from my menuitem , it should restart the browser. I understand the point that i cannot restart without the createBrowser but i am curious if there is jus a shutdown operation that doesnt shutdown my entire app but jus the browser instance...
ramyakrishnan
Mentor
 
Posts: 62
Joined: Wed Sep 16, 2015 12:21 pm

Re: JCEF reloading of browser instances

Postby magreenblatt » Thu Sep 24, 2015 9:36 am

What are you trying to accomplish by closing and re-opening the browser? Why not just load a new URL in the existing browser?
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: JCEF reloading of browser instances

Postby ramyakrishnan » Thu Sep 24, 2015 10:07 am

I did that .. I tried hiding [ when menuitem "close" ] and opening [ when menuitem "open browser"] the browser with the new page .. But i faced another issue there .. I dint know how to shutdown the browser instance when I close my entire JFrame upon which the browser resides , the java application doesnt automatically shutdown the browser instance.. And I dint know how to handle that..


Eg: Imagine i do "close" button from the menuitem and the browser hides , now if i close the entire application using the "X" icon on the JFrame , the browser that is hidden doesnt shutdown .. So my javaw.exe still keeps running even after the frame closes. Am I missing something ? I have written
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); but still i see that the browser instance isnt getting shutdown .. :(
ramyakrishnan
Mentor
 
Posts: 62
Joined: Wed Sep 16, 2015 12:21 pm

Re: JCEF reloading of browser instances

Postby magreenblatt » Thu Sep 24, 2015 10:15 am

Are you calling CefApp.getInstance().dispose() from WindowAdapter.windowClosing? Look at the sample MainFrame.java.
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: JCEF reloading of browser instances

Postby ramyakrishnan » Thu Sep 24, 2015 10:55 am

yes I did something like this :

frame .addWindowListener(new WindowAdapter()
{
@Override

public void windowClosing(WindowEvent e)

{

CefApp.getInstance().dispose()

frame .dispose();

}

}); but that dint work
ramyakrishnan
Mentor
 
Posts: 62
Joined: Wed Sep 16, 2015 12:21 pm

Re: JCEF reloading of browser instances

Postby ramyakrishnan » Mon Sep 28, 2015 9:26 am

Hi ,

I figured that the browser isnt closing because it is in hidden state or it is jus initialized and not loaded when the user would close the entire application. So CefApp.getInstance().dispose() sees no open cef application to close .. Thats y I was getting this error.
ramyakrishnan
Mentor
 
Posts: 62
Joined: Wed Sep 16, 2015 12:21 pm

Re: JCEF reloading of browser instances

Postby harnekmanj » Thu Jan 07, 2016 5:32 pm

I also have the same issue but different workflow and I logged the issue under viewtopic.php?f=17&t=13772

Were you able to solve the problem?
harnekmanj
Techie
 
Posts: 14
Joined: Fri Nov 27, 2015 8:23 pm


Return to JCEF Forum

Who is online

Users browsing this forum: No registered users and 25 guests