Win a copy of The Business Blockchain this week in the Cloud forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Given the xPath, is it possible to highlight an element in JavaFX webView?

 
Naveen Bharadwaj
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
0
down vote
favorite


I have a JavaFX UI where I type a URL and it loads the website in the WebView. There is a textfield where I will specify the xPath. If I press "Find" button, the corresponding element has to be highlighted in the web view. Is it possible using JavaFX or JavaScript or Jsoup?

find.setOnAction(new EventHandler<ActionEvent>() {

@Override
public void handle(ActionEvent arg0) {
String xPath = xpath.getText();
String website = null;
if(url.getText()!=null || !url.getText().isEmpty())
if(url.getText().startsWith("http://"))
website = (url.getText());
else
website = ("http://"+url.getText());
System.out.println(website);
try {
if(website!=null){
Document doc = Jsoup.connect(website).get();
System.out.println(doc.toString());
doc.select(xPath);
}
} catch (IOException e) {
e.printStackTrace();
}

}
});

I have tried using Jsoup, but doesn't seem to work. Jsoup is not mandatory, unless I succeed in highlighting the element in any way possible.
 
John Damien Smith
Ranch Hand
Posts: 296
14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
StackOverflow has a sample of highlighting text in a WebView.

http://stackoverflow.com/questions/19418626/javafx-search-and-highlight-text-add-search-bar-for-loaded-web-page

I don't know if that is what you are asking for or will be helpful to you though.
 
Darryl Burke
Bartender
Posts: 5149
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
John Damien Smith wrote:StackOverflow has a sample ...

And then there's Naveen's own question on SO.

Naveen, please BeForthrightWhenCrossPostingToOtherSites
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic