Prentice Hall and Sun Microsystems. Personal use only; do not redistribute.
54
Chapter 2 First Servlets
Listing 2.12 WebClient.java (continued)
    inputPanel.add(buttonPanel, BorderLayout.SOUTH);
    add(inputPanel, BorderLayout.NORTH);
    Panel resultPanel = new Panel();
    resultPanel.setLayout(new BorderLayout());
    Label resultLabel =
      new Label("Results", Label.CENTER);
    resultLabel.setFont(headingFont);
    resultPanel.add(resultLabel, BorderLayout.NORTH);
    resultArea = new TextArea();
    resultArea.setFont(textFont);
    resultPanel.add(resultArea, BorderLayout.CENTER);
    Panel interruptPanel = new Panel();
    interruptButton = new Button("Interrupt Download");
    interruptButton.addActionListener(this);
    interruptButton.setFont(labelFont);
    interruptPanel.add(interruptButton);
    resultPanel.add(interruptPanel, BorderLayout.SOUTH);
    add(resultPanel, BorderLayout.CENTER);
    setSize(600, 700);
    setVisible(true);
  }
  public void actionPerformed(ActionEvent event) {
    if (event.getSource() == submitButton) {
      Thread downloader = new Thread(this);
      downloader.start();
    } else if (event.getSource() == interruptButton) {
      isInterrupted = true;
    } 
  }
  public void run() {
    isInterrupted = false;
    if (hasLegalArgs()) 
      new HttpClient(host, port, requestLine,
     requestHeaders, resultArea, this);
  }
                         
  public boolean isInterrupted() {
    return(isInterrupted);
  }
  private boolean hasLegalArgs() {
    host = hostField.getTextField().getText();
    if (host.length() == 0) {
      report("Missing hostname");
      return(false);
    }
Second edition of this book: www.coreservlets.com; Sequel: www.moreservlets.com.
Servlet and JSP training courses by book's author: courses.coreservlets.com.






footer




 

 

 

 

 Home | About Us | Network | Services | Support | FAQ | Control Panel | Order Online | Sitemap | Contact

jsp web hosting

 

Our partners: PHP: Hypertext Preprocessor Best Web Hosting Java Web Hosting Jsp Web Hosting Cheapest Web Hosting

Visionwebhosting.net Business web hosting division of Web Design Plus. All rights reserved