title: JTable cell not editable but clickable
body: <p>I want to put an action whenever someone clicks a cell. open another gui for example. But how do i make a cell clickable BUT not editable? These are results for an sql query. I can't manage to make the table uneditable though. Do I need a listener or something? and if yes where should I put it?</p>
  
  <p>Here is my code:</p>
  
  <pre><code>public class AllResultsFromDB extends JFrame
  {
  
      GUI ins = new GUI();
  
      public AllResultsFromDB(GUI x)
      {
          Vector columnNames = new Vector();
  
          Vector data = new Vector();
          this.ins = x;
  
          try
          {   
              // Initializing GUI class in order to call getSelectedTable() method.
  //            GUI ins = new GUI();
              //System.out.println(ins.getSelectedTable());
              Login sgui = new Login();
  
              String dburl = "jdbc:oracle:thin:@localhost:1521:ORCL";
              Connection connection = DriverManager.getConnection( dburl, sgui.getUsername(), sgui.getPassword() );
  
  
              //  Fetch data from table specified by user
  
              String query = "SELECT * FROM "  + ins.getSelectedTable() + " ORDER BY id";
              System.out.println(query);
              Statement stmt = connection.createStatement();
              ResultSet rset = stmt.executeQuery(query);   
              ResultSetMetaData metad = rset.getMetaData();
              int columns = metad.getColumnCount();
  
  
  
              //  This loop gets the names of the columns
  
              for (int i = 1; i &lt;= columns; i++)
              {
                  columnNames.addElement( metad.getColumnName(i) );
                  //columnNames.addElement("PROFILES");
              }
  
  
  
  
              //  This loop gets the data inside the rows
  
              while (rset.next())
              {
                  Vector row = new Vector(columns);
  
                  //Vector b = new Vector((Collection)button);
  
                  for (int i = 1; i &lt;= columns; i++)
                  {
                      row.addElement( rset.getObject(i) );
                  }
  
                  data.addElement( row );
                  //data.addElement(b);
              }
  
              rset.close();
              stmt.close();
              connection.close();
  
  
  
  
              //  Create table with results
  
          JTable table = new JTable(data, columnNames)
          { 
  
              public Class getColumnClass(int column)
              { 
                  for (int row = 0; row &lt; getRowCount(); row++)
                  {
                      Object obj = getValueAt(row, column);
  
  
                      if (obj != null)
                      {
                          return obj.getClass();
                      }
                  }
  
                  return Object.class;
              }
  
          };
  
  
          JScrollPane scroll = new JScrollPane( table );
          getContentPane().add( scroll );
          //table.addMouseListener(l);
          //table.setEnabled(false);
          //table.setDragEnabled(true);
  
  
  
          JPanel panel = new JPanel();
          getContentPane().add( panel, BorderLayout.SOUTH );
  
      } catch (SQLException e) {
          }
  
  
      }
  
  }
  </code></pre>