Con questo fai una ricerca su google.codice:import java.net.*; import java.io.*; import java.awt.*; import java.awt.event.*; import java.applet.*; public class googleSearch extends Applet implements ActionListener { private TextField t; private Button b; private Button grab; public void actionPerformed(ActionEvent ae) { AppletContext ac = this.getAppletContext(); if (ae.getSource().equals(b)) { try { String query = t.getText().replaceAll("\\s+","+"); ac.showDocument(new URL("http://www.google.it/search?hl=it&q="+query+"&meta="), "_blank"); } catch (Exception e) { ac.showStatus(e.toString()); } } else { try { ac.showDocument(new URL(this.getCodeBase()+"/googleSearch.java")); } catch (Exception e) { ac.showStatus(e.toString()); } } } public void init() { this.setLayout(new BorderLayout()); Panel p = new Panel(); t = new TextField(20); b = new Button("Cerca con Google"); b.addActionListener(this); grab = new Button("Scarica sorgente"); grab.addActionListener(this); p.add(t); p.add(b); this.add(p, BorderLayout.NORTH); this.add(grab, BorderLayout.SOUTH); } }
Link all'esempio online
http://www.andrea79.altervista.org/h...gleSearch.html

Rispondi quotando