1

Is there any way to connect google search to jtextfield, i want to create a software that can search directly through a jtextfield and the results would show up on a different JPanel. i found a code that will make it search on google directly but you need an existing browser to do it, i just want the results to appear on a different panel, for example when you search something on the textfield the results will popup on another panel.

this is the code that i found but it needs an existing browser i want the software to be standalone thats all thank you:

try {
         String search = "#q="+jTextField.getText().toString().trim();
         search = search.replaceAll(" ","+");
         String url = "http:////www.google.com//"+search;
         java.awt.Desktop.getDesktop().browse(java.net.URI.create(url));
       }
       catch (java.io.IOException e) {
           System.out.println(e.getMessage());
       }
6od
  • 13
  • 6

1 Answers1

0

If you're not interested in writing your own browser you could use this.

Shiro
  • 2,610
  • 2
  • 20
  • 36