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.  
  7. package pkgApplet;
  8.  
  9. import java.applet.Applet;
  10. import java.awt.Button;
  11. import java.awt.Choice;
  12. import java.awt.GridLayout;
  13. import java.awt.Label;
  14. import java.awt.TextArea;
  15. import java.awt.TextField;
  16. import java.awt.event.ActionEvent;
  17. import java.awt.event.ActionListener;
  18.  
  19. /**
  20.  *
  21.  * @author smit
  22.  */
  23. public class pr17 extends Applet implements ActionListener{
  24. Button b1,b2;
  25. TextArea ta;
  26. TextField t1,t2,t3;
  27. Label l1,l2,l3,l4,l5;
  28. Choice c;
  29. /**
  30.   * Initialization method that will be called after the applet is loaded into
  31.   * the browser.
  32.   */
  33. public void init() {
  34. // TODO start asynchronous download of heavy resources
  35. b1=new Button("ADD");
  36. b2=new Button("Clear");
  37. ta=new TextArea(10,10);
  38. l1=new Label("Roll no");
  39. l2=new Label("Name");
  40. l3=new Label("Course");
  41. l4=new Label("Department");
  42. l5=new Label("Inserted Item");
  43. t1=new TextField();
  44. t2=new TextField();
  45. t3=new TextField();
  46. c=new Choice();
  47. setLayout(new GridLayout(7,2));
  48. b1.addActionListener(this);
  49. b2.addActionListener(this);
  50.  
  51. c.addItem("MCA");
  52. c.addItem("BCOM");
  53. c.addItem("MSC( CA & IT )");
  54.  
  55. add(l1); add(t1);
  56. add(l2); add(t2);
  57. add(l4); add(t3);
  58. add(l3); add(c);
  59. add(b1);
  60. add(b2);
  61. add(l5);
  62. add(ta);
  63.  
  64. }
  65.  
  66. public void actionPerformed(ActionEvent e){
  67. String Roll,Name,Dept,Cou;
  68. Roll=t1.getText();
  69. Name=t2.getText();
  70. Cou=c.getSelectedItem();
  71. Dept=t3.getText();
  72. if(e.getSource()==b1){
  73. ta.append("Rollno: "+Roll+"\nName: "+Name+"\nCourse: "+Cou+"\nDept Name: "+Dept+"\n\n");
  74. }
  75. if(e.getSource()==b2){
  76. ta.selectAll();
  77. ta.setText(null);
  78. t1.setText(null);
  79. t2.setText(null);
  80. t3.setText(null);
  81. c.select(0);
  82. }
  83. }
  84. // TODO overwrite start(), stop() and destroy() methods
  85. }
  86.  

No comments:

Post a Comment

Bottom Ad [Post Page]