title: GUI action listeners for each tab in a tabbed pane
body: <p>I am fairly new to java so bear with me please, basically, below I have a tabbed pane for each of the four rooms in the rooms Arraylist, and I am creating buttons in each tab depending how many lights each room has, How can I associate the buttons in each tab with a specified the rooms?. So like when I click the light button in the Room 1 tab, the event listener knows that the button belongs to the room1?</p>
  
  <p>Any help is appreciated, thanks.</p>
  
  <pre><code>import java.util.ArrayList;
  import java.awt.*;
  import javax.swing.*;
  import java.awt.event.*;
  
  public class MasterGUI extends JFrame implements ActionListener{
  
  public MasterGUI(){
  
  }
  
  public void DisplayFrame(){
      ArrayList&lt;Rooms&gt; rooms;
      rooms = Building.getRoomList();
  
      JFrame master = new JFrame("Solar Master Control Panel"); 
      master.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      Container content = master.getContentPane();
      content.setBackground(Color.lightGray);
  
      JTabbedPane tabbedPane = new JTabbedPane();
      JPanel tmpPanel;
  
      for(int x = 0; x &lt; rooms.size(); x++){
          tmpPanel = new JPanel();
          String roomName = rooms.get(x).getName();
          int id = rooms.get(x).getId();
          tabbedPane.addTab(roomName + " Room " + id, tmpPanel);
      }
  
      for(int x = 0; x &lt; rooms.size(); x++){
          for(int i = 0; i &lt; rooms.get(x).roomLights.size(); i++){
              int num = i + 1;
              ((JPanel) tabbedPane.getComponentAt(x)).add(new JButton("Light" + num));
          }
      }
  
      master.add(tabbedPane, BorderLayout.CENTER);
      master.setSize(800, 600);
      content.add(tabbedPane);
      master.setVisible(true);
  }
  
  public void actionPerformed(ActionEvent e){
  
  }  
  </code></pre>