How do I create a list to store strings in java applet -


i trying create list holds strings inputted user. i'm not sure if code below right way create string, however, created list of strings, string called x assigned textf retrieve user input nothing happens when press button. wanted make sure code below right way add user input secret stored list when press button "b1"

import java.applet.*; import java.awt.event.*; import java.awt.*; import java.util.arraylist;  import java.util.list;  public class test 1 extends applet implements actionlistener {  list<string> wordlist = new arraylist <string>(); font fonttext; textfield textf; string x;  button b1; button b2; button b3; button b4; button b5; button b6;  public void init(){     setbackground(color.lightgray);      fonttext = new font("times new roman", font.bold, 24);      textf = new textfield("", 40);      add(textf);     b1 = new button ("add word list");     b2 = new button ("display words list letter");     b3 = new button ("search list word(show occurence)");     b4 = new button ("remove first occurence of word");     b5 = new button ("remove occurence of word");     b6 = new button ("clear list ");       b1.addactionlistener(this);      b2.addactionlistener(this);      b3.addactionlistener(this);      b4.addactionlistener(this);      b5.addactionlistener(this);      b6.addactionlistener(this);       add(b1);      add(b2);      add(b3);      add(b4);      add(b5);      add(b6); }  public void paint(graphics g){     this.b1.setlocation(20,600);     this.b2.setlocation(150,600);     this.b3.setlocation(400,600);     this.b4.setlocation(680,600);     this.b5.setlocation(930,600);     this.b6.setlocation(1170,600);  }  public void actionperformed(actionevent e){     if (e.getsource() == b1 ){         x = textf.gettext();         wordlist.add(x);     }  } 

}


Comments

Popular posts from this blog

javascript - Slick Slider width recalculation -

jsf - PrimeFaces Datatable - What is f:facet actually doing? -

angular2 services - Angular 2 RC 4 Http post not firing -