java - How to get Specific Array List Item -


i have little issue selecting array list. writing code enable me fix 10 jbuttons in circle, got right, ..... want set actionlistener on each of buttons, don't it, buttons inherit actions required one. how make specific,... here's code.... in advance!

private jbutton quest;  public beginner() {      int n = 10; // no of jbuttons     int radius = 200;     point center = new point(250, 250);     double angle = math.toradians(360 / n);      list<point> points = new arraylist<point>();      points.add(center);      (int = 0; < n; i++) {         double theta = * angle;         int dx = (int) (radius * math.sin(theta));         int dy = (int) (radius * math.cos(theta));         point p = new point(center.x + dx, center.y + dy);         points.add(p);     }      draw(points);  }  public void draw(list<point> points) {      jpanel panels = new jpanel();      springlayout spring = new springlayout();      // layout used     int count = 1;     (point point : points) {          quest = new jbutton("question " + count);         quest.setforeground(color.blue);         font fonte = new font("script mt bold", font.plain, 20);         quest.setfont(fonte);          add(quest);         count++;          spring.putconstraint(springlayout.west, quest, point.x, springlayout.west, panels);          spring.putconstraint(springlayout.north, quest, point.y, springlayout.north, panels);          setlayout(spring);          panels.setopaque(false);         panels.setvisible(true);         panels.setlocation(10, 10);          add(panels);          // action listener set on individual buttons         quest.addactionlistener(new actionlistener() {             public void actionperformed(actionevent a) {                  if (quest.equals(points.get(5)))                     ;                 string c = "hello!";                 joptionpane.showmessagedialog(null, c);             }         });     } } 

the problem expression

if (quest.equals(points.get(5))); 

does nothing. guess should rewritten this

if (quest.equals(points.get(5))) {     string c = "hello!";     joptionpane.showmessagedialog(null, c); } 

Comments