title: Enabling/Disabling of Button inside cell's JTable, NullPointerException
body: <p>I wrote my own custom objects classes... I Populate my JTable with my custom class, really it's a button like example.</p>
  
  <p>I want to invoke the ActionEvent of Button locate in 1st row... and I want to enable (from 1st button row) and disable (from 2nd button row) the button in 3th row...</p>
  
  <p>I don't know how to do it...</p>
  
  <p>Here my Class code:</p>
  
  <pre><code>class CompButton extends JPanel {
  
    private final JButton intButton = new JButton();
  
    CompButton(ButtonInfo info) {
      super();
      setInfo(info);
      info.setOwner(this); // Another Try
      setLayout(new BoxLayout(this, BoxLayout.LINE_AXIS));
      add(intButton);
    }
  
    public ButtonInfo getInfo() {
      return new ButtonInfo(intButton.getText());
    }
  
    public void setEnableButton(boolean enable) {
      intButton.setEnabled(enable);
    }
  
    public void setInfo(ButtonInfo info) {
      for (ActionListener al : intButton.getActionListeners()) {
        intButton.removeActionListener(al);
      }
      if (info.getInfoText().toLowerCase().equals("red")) {
        intButton.setForeground(new Color(255, 0, 0));
        intButton.setText(info.getInfoText().toUpperCase());
        //Disable Blue Button, in Row 2 (3th row) or Cell(2,0)
        intButton.addActionListener((ActionEvent e) -&gt; {
          System.out.println("Red Button Pressed");
          JTable table = (JTable)SwingUtilities.getAncestorOfClass(
              JTable.class, (Component) e.getSource());
          //table.getModel()).DisableButtonInCell(2,0)
          ButtonInfo binfo = (ButtonInfo)table.getModel().getValueAt(2, 0);
          //CompButton owner = binfo.getOwner();
          CompButton owner = new CompButton(binfo);
          owner.setEnableButton(false);
        });
      }
      if (info.getInfoText().toLowerCase().equals("green")) {
        intButton.setForeground(new Color(0, 196, 0));
        intButton.setText(info.getInfoText().toUpperCase());
        //Enable Blue Button, in Row 2 (3th row) or Cell(2,0)
        intButton.addActionListener((ActionEvent e) -&gt; {
          System.out.println("green Button Pressed");
          JTable table = (JTable)SwingUtilities.getAncestorOfClass(
              JTable.class, (Component) e.getSource());
          //table.getModel()).EnableButtonInCell(2,0)
          ButtonInfo binfo = (ButtonInfo)table.getModel().getValueAt(2, 0);
          //CompButton owner = binfo.getOwner();
          CompButton owner = new CompButton(binfo);
          owner.setEnableButton(true);
        });
      }
      if (info.getInfoText().toLowerCase().equals("blue")) {
        intButton.setForeground(new Color(32, 32, 255));
        intButton.setText(info.getInfoText().toUpperCase());
        //DoClick Red Button, in Row 0 (1st row) or Cell(0,0)
        intButton.addActionListener((ActionEvent e) -&gt; {
          System.out.println("blue Button Pressed");
          JTable table = (JTable)SwingUtilities.getAncestorOfClass(
              JTable.class, (Component) e.getSource());
          //table.getModel()).DoClickButtonInCell(0,0)
          ButtonInfo binfo = (ButtonInfo)table.getModel().getValueAt(0, 0);
          //CompButton owner = binfo.getOwner();
          CompButton owner = new CompButton(binfo);
          owner.intButton.doClick();
        });
      }
    }
  }
  </code></pre>
  
  <p>In my <strong>makeUI</strong> method, you can see, my Class populate the table</p>
  
  <pre><code>  public JComponent makeUI() {
      JPanel panel = new JPanel();
      panel.setLayout(new BoxLayout(panel, BoxLayout.PAGE_AXIS));
      JTable table = new JTable(new DefaultTableModel(
          new Object [][] {
            { new ButtonInfo("RED") },
            { new ButtonInfo("GREEN") },
            { new ButtonInfo("BLUE") }
          }, new String [] {" "}));
      table.getColumnModel().getColumn(0).setCellEditor(new EdtrRndr());
      table.getColumnModel().getColumn(0).setCellRenderer(new EdtrRndr());
      jscrollpane.setViewportView(table);
      panel.add(jscrollpane);
      return panel;
    }
  </code></pre>
  
  <p>I put all code to help me.</p>
  
  <pre><code>import java.awt.*;
  import java.awt.event.*;
  import javax.swing.*;
  import javax.swing.table.*;
  
  public class TableWithButtons {
    final JScrollPane jscrollpane = new JScrollPane();
    static JFrame frame = new JFrame();
  
    public JComponent makeUI() {
      JPanel panel = new JPanel();
      panel.setLayout(new BoxLayout(panel, BoxLayout.PAGE_AXIS));
      JTable table = new JTable(new DefaultTableModel(
          new Object [][] {
            { new ButtonInfo("RED") },
            { new ButtonInfo("GREEN") },
            { new ButtonInfo("BLUE") }
          }, new String [] {" "}));
      table.getColumnModel().getColumn(0).setCellEditor(new EdtrRndr());
      table.getColumnModel().getColumn(0).setCellRenderer(new EdtrRndr());
      jscrollpane.setViewportView(table);
      panel.add(jscrollpane);
      return panel;
    }
  
    public static void main(String... args) {
      EventQueue.invokeLater(() -&gt; {
        frame.getContentPane().add(new TableWithButtons().makeUI());
        frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
        frame.setSize(240, 240);
        frame.setSize(240, 240);
        frame.setVisible(true);
      });
    }
  }
  
  class CompButton extends JPanel {
  
    private final JButton intButton = new JButton();
  
    CompButton(ButtonInfo info) {
      super();
      setInfo(info);
      info.setOwner(this); // Another Try
      setLayout(new BoxLayout(this, BoxLayout.LINE_AXIS));
      add(intButton);
    }
  
    public ButtonInfo getInfo() {
      return new ButtonInfo(intButton.getText());
    }
  
    public void setEnableButton(boolean enable) {
      intButton.setEnabled(enable);
    }
  
    public void setInfo(ButtonInfo info) {
      for (ActionListener al : intButton.getActionListeners()) {
        intButton.removeActionListener(al);
      }
      if (info.getInfoText().toLowerCase().equals("red")) {
        intButton.setForeground(new Color(255, 0, 0));
        intButton.setText(info.getInfoText().toUpperCase());
        //Disable Blue Button, in Row 2 (3th row) or Cell(2,0)
        intButton.addActionListener((ActionEvent e) -&gt; {
          System.out.println("Red Button Pressed");
          JTable table = (JTable)SwingUtilities.getAncestorOfClass(
              JTable.class, (Component) e.getSource());
          //table.getModel()).DisableButtonInCell(2,0)
          ButtonInfo binfo = (ButtonInfo)table.getModel().getValueAt(2, 0);
          //CompButton owner = binfo.getOwner();
          CompButton owner = new CompButton(binfo);
          owner.setEnableButton(false);
        });
      }
      if (info.getInfoText().toLowerCase().equals("green")) {
        intButton.setForeground(new Color(0, 196, 0));
        intButton.setText(info.getInfoText().toUpperCase());
        //Enable Blue Button, in Row 2 (3th row) or Cell(2,0)
        intButton.addActionListener((ActionEvent e) -&gt; {
          System.out.println("green Button Pressed");
          JTable table = (JTable)SwingUtilities.getAncestorOfClass(
              JTable.class, (Component) e.getSource());
          //table.getModel()).EnableButtonInCell(2,0)
          ButtonInfo binfo = (ButtonInfo)table.getModel().getValueAt(2, 0);
          //CompButton owner = binfo.getOwner();
          CompButton owner = new CompButton(binfo);
          owner.setEnableButton(true);
        });
      }
      if (info.getInfoText().toLowerCase().equals("blue")) {
        intButton.setForeground(new Color(32, 32, 255));
        intButton.setText(info.getInfoText().toUpperCase());
        //DoClick Red Button, in Row 0 (1st row) or Cell(0,0)
        intButton.addActionListener((ActionEvent e) -&gt; {
          System.out.println("blue Button Pressed");
          JTable table = (JTable)SwingUtilities.getAncestorOfClass(
              JTable.class, (Component) e.getSource());
          //table.getModel()).DoClickButtonInCell(0,0)
          ButtonInfo binfo = (ButtonInfo)table.getModel().getValueAt(0, 0);
          //CompButton owner = binfo.getOwner();
          CompButton owner = new CompButton(binfo);
          owner.intButton.doClick();
        });
      }
    }
  }
  
  class ButtonInfo {
  
    private String text = "";
    private CompButton owner;
  
    ButtonInfo(String text) {
      this.text = text;
      //owner = new CompButton(this);
    }
  
    public void setInfoText(String text) {
      this.text = text;
    }
  
    public String getInfoText() {
      return text;
    }
  
    public void setOwner(CompButton owner) {
      this.owner = owner;
    }
  
    public CompButton getOwner() {
      return this.owner;
    }
  }
  
  class EdtrRndr extends AbstractCellEditor implements TableCellRenderer, TableCellEditor {
    private CompButton cmpbtne = new CompButton(new ButtonInfo("RED"));
    private CompButton cmpbtnr = new CompButton(new ButtonInfo("RED"));
    @Override
    public Object getCellEditorValue() {
      return cmpbtne.getInfo();
    }
    @Override
    public Component getTableCellEditorComponent(JTable table, Object value,
        boolean isSelected, int row, int column) {
      cmpbtne.setInfo((ButtonInfo) value);
      return cmpbtne;
    }
    @Override
    public Component getTableCellRendererComponent(JTable table,
        Object value, boolean isSelected, boolean hasFocus, int row, int column) {
      cmpbtnr.setInfo((ButtonInfo) value);
      return cmpbtnr;
    }
  }
  </code></pre>
  
  <p><em>How performs doClick() in Button contained in cell of JTable?</em></p>
  
  <p>and</p>
  
  <p><em>How enable/disable Button contained in cell of JTable?</em></p>