title: How can I make a JTable cell do different things on single-click than on double-click?
body: <p>I am using an editable <code>JTable</code> that contains a column named Subject. When the first row is empty and the user clicks on a subject cell to add new task, by default, the user has to click twice to make the cell editable. I want to make it editable on single-click and have it open another form on double-click. I have tried <code>MouseListener</code> but have not been able to solve it. Is there a way to solve this problem? If so, what is it?</p>
  
  <p>My code:</p>
  
  <pre><code>class mouseRenderer extends DefaultTableCellRenderer {
      JLabel lblcell = new JLabel();
  
      public Component getTableCellRendererComponent(JTable table, Object obj, boolean isSelected, boolean hasFocus, int row,
              int column) {
          ttable.addMouseListener(new MouseAdapter() {
              public void mouseClicked(MouseEvent e) {
                  selrow = ttable.getSelectedRow();
                  selcol = ttable.getSelectedColumn();
  
                  if(e.getClickCount() == 1) {
                      if(selrow == 0) {
                          lblcell.setText("");
                      }
                  }
              }
          });
          return lblcell;
      }
  }
  </code></pre>