javafx.scene.web.WebHistory Java Examples

The following examples show how to use javafx.scene.web.WebHistory. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: WebTab.java    From BowlerStudio with GNU General Public License v3.0 6 votes vote down vote up
public String goBack()
    {    
    	//new Exception().printStackTrace(System.err);
      final WebHistory history=webEngine.getHistory();
      ObservableList<WebHistory.Entry> entryList=history.getEntries();
      int currentIndex=history.getCurrentIndex();
//      Out("currentIndex = "+currentIndex);
//      Out(entryList.toString().replace("],","]\n"));

      Platform.runLater(() ->{
    	  try{
    		  history.go(-1);
    	  }catch(Exception e){
    		 // e.printStackTrace();
    	  }
      });
      return entryList.get(currentIndex>0?currentIndex-1:currentIndex).getUrl();
    }
 
Example #2
Source File: WebTab.java    From BowlerStudio with GNU General Public License v3.0 6 votes vote down vote up
public String goForward()
    {    
      final WebHistory history=webEngine.getHistory();
      ObservableList<WebHistory.Entry> entryList=history.getEntries();
      int currentIndex=history.getCurrentIndex();
//      Out("currentIndex = "+currentIndex);
//      Out(entryList.toString().replace("],","]\n"));
    
		Platform.runLater(() -> {
			try {
				history.go(1);
			} catch (IndexOutOfBoundsException ex) {
			}
		});
      return entryList.get(currentIndex<entryList.size()-1?currentIndex+1:currentIndex).getUrl();
    }
 
Example #3
Source File: HTMLView.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
public HTMLView() {
    viewport = ToolBarContainer.createDefaultContainer(Orientation.RIGHT);
    webView = new WebView();
    viewport.setContent(webView);
    VLToolBar bar = new VLToolBar();
    Button openInBrowser = FXUIUtils.createButton("open-in-browser", "Open in External Browser", true);
    Button prevPage = FXUIUtils.createButton("prev", "Previous Page", false);
    WebHistory history = webView.getEngine().getHistory();
    prevPage.setOnAction((event) -> {
        history.go(-1);
    });
    bar.add(prevPage);
    Button nextPage = FXUIUtils.createButton("next", "Next Page", false);
    nextPage.setOnAction((event) -> {
        history.go(1);
    });
    bar.add(nextPage);
    openInBrowser.setOnAction((event) -> {
        try {
            URI uri = ProjectHTTPDServer.getURI(fileHandler.getCurrentFile().toPath());
            if (uri != null)
                Desktop.getDesktop().browse(uri);
            else
                Desktop.getDesktop().open(fileHandler.getCurrentFile());
        } catch (IOException e) {
            e.printStackTrace();
        }
    });
    bar.add(openInBrowser);
    history.currentIndexProperty().addListener((ob, o, n) -> {
        nextPage.setDisable(n.intValue() == history.getEntries().size() - 1);
        prevPage.setDisable(n.intValue() == 0);
    });
    viewport.getToolBarPanel().add(bar);
}
 
Example #4
Source File: BrowserJFX.java    From mars-sim with GNU General Public License v3.0 5 votes vote down vote up
public String getCurrentURL() {
  //history = engine.getHistory();
  ObservableList<WebHistory.Entry> entryList = history.getEntries();
  int currentIndex = history.getCurrentIndex();
  String txt = null;
  if (currentIndex >=0 ) {
  	txt = entryList.get(currentIndex).getUrl();
  }
  return txt;
}