title: Java how to assign id to button and retrieve them?
body: <p>I'm getting stuck while building a forum like application which has a vote button.</p>
  
  <p>I have vote up and vote down button for each content which are automatically generated. I want this button to only display the up and down arrow but not any text or label.. how can i find out which button is pressed?</p>
  
  <p>Automated content.. </p>
  
  <pre><code>ImageIcon upvote = new ImageIcon(getClass().getResource("vote_up.png"));
  ImageIcon downvote = new ImageIcon(getClass().getResource("vote_down.png"));
  JButton vote_up = new JButton(upvote);
  JButton vote_down = new JButton(downvote);
  vote_up.addActionListener(voting);
  vote_down.addActionListener(voting);
  
  Action voting = new AbstractAction(){
      @Override
      public void actionPerformed(ActionEvent e){
          //What to do here to find out which button is pressed?
      }
  };
  </code></pre>
  
  <p>any help is appreciated.</p>
  
  <pre><code>public void a(){
      int crt_cnt = 0;
      for(ClassA temp : listofClassA)
      {                    
          b(crt_cnt);
          crt_cnt++;
      }
  
  }
  public void b(crt_cnt){
       //draw button
  }
  </code></pre>
  
  <p>As from above, I have multiple vote_up and vote_down button created by the b function, how can i differentiate which crt_cnt is the button from?</p>