import CS342.Hwk3.*; import java.net.URL; import java.applet.Applet; import java.awt.Panel; import java.awt.TextField; import java.awt.TextComponent; import java.awt.Component; import java.awt.Label; import java.awt.TextArea; /** * This class shows how to use the CS342.Hwk3 package (specifically the * classes DefaultDisplay and URLTokenizer) to display a file. This forms * a basis for the third homework task. */ public class Homework3Base extends DefaultDisplay { /** * The method defines process_input(String) and so makes this a * concrete class that is extending an abstract class. Notice that * we don't need to define either init or handleEvent as they are * taken care of in the DefaultDisplay definition. */ public void process_input(String the_url_name) { URLTokenizer the_url_tokenizer; try { the_url_tokenizer = new URLTokenizer(the_base_url, the_url_name); } catch (URLTokenizerException the_exception) { the_text_output.appendText(the_exception.getMessage()); return; } try { for(;;) { String the_word_just_read = the_url_tokenizer.nextToken(); if (the_word_just_read.equals("")) { the_text_output.appendText(" -- have finished reading " + the_url_name + "\n"); break; } the_text_output.appendText(the_word_just_read + "\n"); } } catch(URLTokenizerException the_exception) { the_text_output.appendText(the_exception.getMessage()); return; } } }