Full width home advertisement

HTML

Tech News

Ad

  1. /*
  2.  * To change this license header, choose License Headers in Project Properties.
  3.  * To change this template file, choose Tools | Templates
  4.  * and open the template in the editor.
  5.  */
  6. package pkgApplet;
  7.  
  8. import java.applet.Applet;
  9. import java.awt.Button;
  10. import java.awt.List;
  11. import java.awt.TextField;
  12. import java.awt.event.ActionEvent;
  13. import java.awt.event.ActionListener;
  14.  
  15. /**
  16.  *
  17.  * @author smit
  18.  */
  19. public class pr21 extends Applet implements ActionListener {
  20.  
  21. Button b1;
  22. List li;
  23. TextField tf;
  24.  
  25. /**
  26.   * Initialization method that will be called after the applet is loaded into
  27.   * the browser.
  28.   */
  29. public void init() {
  30. // TODO start asynchronous download of heavy resources
  31. b1 = new Button("FIND");
  32. li = new List(10);
  33. tf = new TextField();
  34.  
  35. add(tf);
  36. add(b1);
  37. add(li);
  38.  
  39. b1.addActionListener(this);
  40. }
  41.  
  42. public void actionPerformed(ActionEvent e) {
  43. int n, ans;
  44.  
  45. n = Integer.parseInt(tf.getText());
  46. for (int i = 1; i <= 10; i++) {
  47. ans = n * i;
  48. li.add(n + " x " + i + " =" + ans);
  49. }
  50. }
  51. // TODO overwrite start(), stop() and destroy() methods
  52. }
  53.  

No comments:

Post a Comment

Bottom Ad [Post Page]