|
| |
|
|
|
|
|
|
|
|
|
|
| |
|
|
|
|
|
|
Topic : Search Yahoo
|
|
Author : Paul k.
|
Total Visits: 240
|
|
Published Date:
Tuesday, April 18, 2000
|
|
|
import
java.applet.Applet;
import java.awt.*;
import java.net.*;
import java.io.*;
public class SearchYahoo extends Applet {
//--------------------------------------------------------------
TextField searchField;
//--------------------------------------------------------------
public void init() {
Label title = new Label("Enter a string to send to Yahoo");
title.setFont(new Font("Helvetica", Font.BOLD, 18));
title.setBackground(Color.red);
title.setForeground(Color.yellow);
add(title);
add(new Button("Search Yahoo"));
searchField = new TextField(20);
add(searchField);
}
//--------------------------------------------------------------
// Events from *either* Button or TextField should trigger this.
public boolean action(Event event, Object object) {
String searchString = searchField.getText();
if (searchString.equals(""))
searchString = "Java";
Show(searchString);
return(true);
}
//--------------------------------------------------------------
public void Show(String searchString) {
try {
URL yahoo=new URL("http://search.yahoo.com/bin/search?p="
+ searchString);
getAppletContext().showDocument(yahoo);
} catch(Exception e) {
System.out.println("Error: " + e);
}
}
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|