title: Unable to lose jComboBox in a jTable focus
body: <p>I have a jTable that has a jComboBox column. However I had an issue where I couldn't get the jComboBox to show unless you first click on it. Other people have had the <a href="https://forums.oracle.com/thread/1221919" rel="nofollow">same problem</a>, <a href="https://forums.oracle.com/thread/1363986" rel="nofollow">it seems</a>.</p>
  
  <p>So I then learned I needed to make a CellRenderer besides the CellEditor. And so I did...</p>
  
  <pre><code>public class MyCellRenderer extends JComboBox&lt;CustomItem&gt; implements TableCellRenderer{
      @Override
      public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column){
          if(isSelected){
              setForeground(table.getSelectionForeground());
              super.setBackground(table.getSelectionBackground());
          } else{
              setForeground(table.getForeground());
              setBackground(table.getBackground());
          }
          setSelectedItem(value);
          return this;
      }
  }
  </code></pre>
  
  <p>By the way, I am also using a ComboBoxRenderer because I need it to display text while containing an item.</p>
  
  <pre><code>public class MyComboBoxRenderer extends BasicComboBoxRenderer{
      @Override
      public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus){
          super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
          if(value != null){
              CustomItem customItem = (CustomItem) value;
              setText(customItem.getText());
          }
          if(index == -1){
              CustomItem customItem = (CustomItem) value;
              setText("" + customItem.getText());
          }
          return this;
      }
  }
  </code></pre>
  
  <p>And now it works! It does show the jComboBox in my jTable by default <strong>BUT</strong> now each jComboBox on each row has permanent focus! And only the first one I click on actually displays the menu. The rest are 'selected' but they do not respond.</p>
  
  <p><strong>Edit:</strong> Here is how I create the table.</p>
  
  <pre><code>private void initializeTable(){
      JTable jTable1 = new javax.swing.JTable();
      DefaultTableModel dtm = new DefaultTableModel();
      dtm.addColumn("one");
      dtm.addColumn("two");
      dtm.addColumn("three");
      jTable1.setModel(dtm);
  
      JComboBox&lt;CustomItem&gt; items = new JComboBox&lt;&gt;();
      items.setRenderer(new MyComboBoxRenderer());
      items.add(new CustomItem(1, "soup", false);
      items.add(new CustomItem(33, "sauce", false);
      items.setSelectedIndex(0);
  
      jTable1.getColumnModel().getColumn(2).setCellEditor(new DefaultCellEditor(items));
      jTable1.getColumnModel().getColumn(2).setCellRenderer(new MyCellRenderer());
  }
  </code></pre>