title: Display JLabel inside a JTable
body: <p>I am trying to display a <code>JLabel</code> inside a <code>JTable</code> by overriding the <code>getColumnClass</code> method like this</p>
  
  <pre><code>        JLabel myLabel = new JLabel("ok");
          String[] columnNames = {"","",""};
          Object[][] data =
              {
                  {myLabel, myLabel, myLabel},
                  {myLabel, myLabel, myLabel},
                  {myLabel, myLabel, myLabel},
              };
  
  
          DefaultTableModel model = new DefaultTableModel(data, columnNames);
          table = new JTable( model )
          {
              public Class getColumnClass(int column)
              {
                      return JLabel.class;
              }
          };
  </code></pre>
  
  <p>But instead it displays something like this (hashcode ?)</p>
  
  <pre><code>javax.swing.JLabel[,0,0,0x0,invalid,alignmentX=0.0,alignmentY=0.0,border=,flags=8388608,maximumSize=,minimumSize=,preferredSize=,defaultIcon=,disabledIcon=,horizontalAlignment=LEADING,horizontalTextPosition=TRAILING,iconTextGap=4,labelFor=,text=ok,verticalAlignment=CENTER,verticalTextPosition=CENTER]
  </code></pre>
  
  <p>What is the problem and how do i fix this?</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>The code works fine if use the same logic to display an <code>ImageIcon</code></p>
  
  <pre><code>        ImageIcon myLabel = new ImageIcon(path);  // ignore the variable name
  </code></pre>
  
  <p>and change to <code>getColumnClass</code></p>
  
  <pre><code>            public Class getColumnClass(int column)
              {
                      return ImageIcon.class;
              }
  </code></pre>