title: Java - How to make JComboBox of non-String objects display String names?
body: <p><img src="https://i.stack.imgur.com/FtLYG.png" alt="Imgur"></p>
  
  <p>I would like to make the <code>JComboBox</code> component display <code>String</code> names, rather than references. However, I don't know how that is done.</p>
  
  <p>Below shows my codes:</p>
  
  <pre><code>public class Properties extends JPanel implements ItemListener {
      private static final long serialVersionUID = -8555733808183623384L;
      private static final Dimension SIZE = new Dimension(130, 80);
      private JComboBox&lt;Category&gt; tileCategory;
  
      public Properties() {
          tileCategory = new JComboBox&lt;Category&gt;();
          tileCategory.setPreferredSize(SIZE);
          tileCategory.addItemListener(this);
  
          this.setLayout(new GridLayout(16, 1));
          loadCategory();
      }
  
      private void loadCategory() {
          //Obtains a HashMap of Strings from somewhere else. All of this is constant, so they
          //aren't modified at runtime.
          HashMap&lt;Integer, String&gt; map = EditorConstants.getInstance().getCategoryList();
  
          DefaultComboBoxModel&lt;Category&gt; model = (DefaultComboBoxModel&lt;Category&gt;) this.tileCategory.getModel();
          for (int i = 0; i &lt; map.size(); i++) {
              Category c = new Category();
              c.name = map.get(i + 1);
              model.addElement(c);
          }
          this.add(tileCategory);
      }
  }
  </code></pre>
  
  <p>The only thing I know is that I passed <code>Category</code> class to <code>JComboBox</code>. Below shows the <code>Category</code> class:</p>
  
  <pre><code>public class Category {
      public String name;
  }
  </code></pre>
  
  <p>And that's about it. </p>
  
  <p>My only goal is to get the <code>Category.name</code> member variable show up in the <code>JComboBox</code> drop-down list, where the rectangle is marking in the picture.</p>
  
  <p>Can anyone show me how this is done? Thanks in advance.</p>