title: Creating a Custom JComboBox
body: <p>This is my first attempt to create a custom swing component. I am trying to create a JComboBox that will be used for numerous cells in a JTable. When my JTable is displayed the cells that should contain combo boxes look correct.
  <a href="https://i.stack.imgur.com/qwZHj.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/qwZHj.png" alt="enter image description here"></a>
  However, when I click on any of the boxes, the list is not displayed. Nothing happens. Here is my code:</p>
  
  <pre><code>public class TimeLineComboBox extends JComboBox&lt;String&gt; {
  
  /**
   * 
   */
  private static final long serialVersionUID = 1L;
  
  private String item="";
  private TimelineRecord timeLine=null;
  
  public TimeLineComboBox(String[] list_,TimelineRecord timeLine_,String item_,Boolean editable_) {
      super(list_);
      this.addActionListener(listener());
      timeLine=timeLine_;
      item=item_;
  }
  
  private ActionListener listener() {
      ActionListener actionListener=new ActionListener() {
  
          @Override
          public void actionPerformed(ActionEvent e) {
              @SuppressWarnings("unchecked")
              String value=(String) ((JComboBox&lt;String&gt;) e.getSource()).getSelectedItem();
              switch(item) {
                  case "meat":
                      timeLine.meat=value;
                      break;
                  case "monitor":
                      timeLine.monitor=Configuration.getInstance().getMonitorByName(value);
                      break;
                  case "pit":
                      timeLine.pit=Configuration.getInstance().getMonitorByName(value);
                      break;
                  case "event":
                      timeLine.eventText=value;
                      break;
                  default:
                      JOptionPane.showMessageDialog(GUI.getInstance().getFrame(),"Internal Error: Unknown selection list: "+item,"Internal Error",JOptionPane.ERROR_MESSAGE);
              }
          }
  
      };
      return(actionListener);
  }
  
  }
  </code></pre>