I'm making a swing application with Url load in JavaFX browser inside frame. I have to divide that browser frame in to two parts as in left side of frame content will be show and in right side image will be show.
import java.awt.BorderLayout;
import javafx.application.Application;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.collections.ObservableList;
import javafx.concurrent.Worker;
import javafx.concurrent.Worker.State;
import javafx.embed.swing.JFXPanel;
import javafx.scene.Group;
import javafx.scene.Node;
import javafx.scene.Scene;
import javafx.scene.control.ScrollPane;
import javafx.scene.web.WebEngine;
import javafx.scene.web.WebView;
import javafx.stage.Stage;
public class Main extends Application {
@Override
public void start(final Stage stage) {
stage.setWidth(400);
stage.setHeight(500);
Scene scene = new Scene(new Group());
//Group root = new Group();
// Scene scene = new Scene(root,80,20);
final WebView browser = new WebView();
final WebEngine webEngine = browser.getEngine();
ScrollPane scrollPane = new ScrollPane();
scrollPane.setContent(browser);
webEngine.getLoadWorker().stateProperty()
.addListener(new ChangeListener<State>() {
@Override
public void changed(ObservableValue ov, State oldState, State newState) {
if (newState == Worker.State.SUCCEEDED) {
stage.setTitle(webEngine.getLocation());
stage.setTitle(webEngine.getLocation());
String trgurl=webEngine.getLocation();
System.out.println(trgurl);
if(trgurl.matches("(.*)img=(.*)")){
int n = trgurl.indexOf("&img=");
System.out.println(n+7);
int len = trgurl.length();
System.out.println("string length is:
"+trgurl.length());
System.out.println(trgurl.substring(n+7,len));
String find = "file://"+trgurl.substring(n+7,len);
System.out.println(find);
try {
new File(find).toURI().toURL();
}
catch(Exception e){
}
}
}
}
});
webEngine.load("http://www.example.com");
scene.setRoot(scrollPane);
stage.setScene(scene);
stage.show();
stage.setResizable(true);
}
private static void extracted(String[] args) {
launch(args);
}
}
When I load this url in left side of scrollpane content is loading but in right side no image is loading other than that there is no error in this program. And if i try to add browser to internal frame how is it possible