title: Why is my JTable not showing up?
body: <p>My JTable is not showing up. I don't have a clue why. maybe you can help me. I have a Window Class which has a right panel and the right panel should show a table with model data. I have used dummy data to start off with such as Month and Days.</p>
  
  <p>Here is the Right Panel Class</p>
  
  <pre><code>import model.*;
  
  
  import java.awt.*;
  import java.awt.event.*;
  //import java.text.*;
  import javax.swing.*;
  
  
  public class RightPanel extends JPanel implements View
  {
      private TablePanel songsnartists = new TablePanel();
      Shop shop;
  
      public RightPanel(Shop ourShop)
      {   
          shop = ourShop;
          setup();
          build();
          setVisible(true);
      }
  
      private void setup()
      {   
          setPreferredSize(new Dimension(300, 300));
          setLayout(new GridLayout(3,2));
          setBorder(BorderFactory.createLineBorder(Color.blue));
      }
  
      private void build()
      { 
          add(songsnartists);
      }
  
      public void update()
      {}
  }
  </code></pre>
  
  <p>/* simple enough so far just trying to add the table panel to my right panel */</p>
  
  <p>Here is the TablePanel class that I created. It inherits JTable and uses a private class MyTableModel which inherits AbstractTableModel in order for me to make an uneditable table.</p>
  
  <pre><code>import javax.swing.*;
  import javax.swing.table.*;
  
  
  public class TablePanel extends JTable
  {
      //private int ROWS = 3;
      //private int COLUMNS = 2;
      private final String [][] data = {{"Jan", "31"}, {"Feb","28"},{"Mar","31"}};
      private final String[] headers = {"Month", "Days"};
      JTable table;
  
  
      public TablePanel()
      {
          table = new JTable(new MyTableModel(data, headers));
          JTableHeader header = table.getTableHeader();
          //header.setBackground(Color.blue);
          setVisible(true);
      }
  
      private class MyTableModel extends AbstractTableModel
      {
          private String[] columnNames = {"Month", "Days"};
          private String[][] data = {{"Jan", "31"}, {"Feb","28"},{"Mar","31"}};
  
          public MyTableModel(String [][] data, String [] header)
          {
              int rows, cols, rowCounter, colCounter;
  
              rows = getRowCount();
              cols = getColumnCount();
  
              for (rowCounter=0; rowCounter &lt; rows; rowCounter++)
                  {
                      for (colCounter=0; colCounter &lt; cols; colCounter++)
                          {
                              setValueAt(data[rowCounter][colCounter],rowCounter,colCounter);
                          }
                  }           
          }
  
  
          public int getColumnCount()
          {
              return columnNames.length;
          }
  
          public int getRowCount()
          {
              return data.length;
          }
  
          public String getColumnName(int col)
          {
              return columnNames[col];
          }
  
          public Object getValueAt(int row, int col)
          {
              return data[row][col];
          }
  
          public Class getColumnClass(int c) 
          {
              return getValueAt(0, c).getClass();
          }
  
          public boolean isCellEditable(int row, int col)
          {
              return false;
          }
      }
  }
  </code></pre>
  
  <p>As you can see the abstract methods are overridden in the private class. Can anyone help me to show me why my JTable is not showing up?</p>