title: JTable cell changes when clicking Button?
body: <p>I have a table with a tablemodel containg some names and a CellRenderer which extends a Panel I made which contains a JButton. Everythign works great except when I click on the button the values in the Cell disappear as long as I hold the JButton clicked!? bellow the Panel and the Renderer. Any ideas?</p>
  
  <pre><code>        package gui.table;
  
      import event.TestController;
      import gui.DaimlerColor;
      import gui.MainWindow;
  
      import java.awt.Component;
      import java.util.LinkedList;
      import java.util.List;
  
      import javax.swing.BorderFactory;
      import javax.swing.JTable;
      import javax.swing.table.TableCellRenderer;
  
      import org.jdom2.Document;
      import org.jdom2.Element;
  
  
      @SuppressWarnings("serial")
      public class TestcaseCellRenderer extends TestcasePanel implements TableCellRenderer {
  
          List&lt;String&gt; data;
          MainWindow gui = null;
          TestController tgc = null;
  
          public TestcaseCellRenderer() {
              super();
              setName("Table.cellRenderer");
          }
  
          public TestcaseCellRenderer(List&lt;String&gt; names, MainWindow gui2, TestController tgc) {
              super();
              this.data = names;
              this.gui = gui2;
              this.tgc = tgc;
              setName("Table.cellRenderer");
          }
  
          @Override
          public Component getTableCellRendererComponent(JTable table, Object value,
                  boolean isSelected, boolean hasFocus, int row, int column) {
  
              //this.setBackground(isSelected ? table.getSelectionBackground() : table
              //      .getBackground());
  
              this.setOpaque(true);
              this.setToolTipText("Click play to rerun this Testcase");
  
              this.setName(data.get(row));
  
              //set Button Image if passed
              int passed = 0;
  
              setPlaybuttonIcon(gui.getTestcasetableModelIcon(row));
  
              setClickable(tgc.clickable);
  
  
              if (row &lt;= gui.currentTestcase) {
                  Document doc = tgc.getDoc();
                  List&lt;Element&gt; cases = doc.getRootElement().getChildren();
                  List&lt;Element&gt; teststeps = cases.get(row).getChildren();
                  List&lt;String&gt; attributes = new LinkedList();
                  for (Element teststep : teststeps) {
  
  
                      if (teststep.getAttribute("status") != null) {
                          attributes.add(teststep.getAttributeValue("status"));
                      }
                      else{
                          attributes.add("empty");
                      }
  
                  }
                  if(attributes.contains("empty")){
                      setButton("");
                  }
                  else if (attributes.contains("failed")){
  
                      setButton("failed");
                  }
                  else{
                      setButton("passed");
                  }
  
              } else {
                  setButton("");
              }
  
              this.setBorder(BorderFactory.createEmptyBorder());
              this.setBackground(isSelected ?  DaimlerColor.LIGHT_BLUE : (row % 2 == 1 ? DaimlerColor.DARK_WHITE : DaimlerColor.WHITE));
              return this;
          }
  
  
      }
  
  
  
      package gui.table;
  import gui.MainWindow;
  
  import java.awt.GridBagConstraints;
  import java.awt.GridBagLayout;
  import java.awt.Image;
  import java.awt.Insets;
  
  import javax.swing.ImageIcon;
  import javax.swing.JButton;
  import javax.swing.JLabel;
  import javax.swing.JPanel;
  
  @SuppressWarnings("serial")
  public class TestcasePanel extends JPanel {
      public  JButton playButton = new JButton();// new JButton("Play");
      //
      String name = "-";
      JLabel nameLabel = new JLabel(name);
      JLabel statusIconLabel = new JLabel();
      public MainWindow gui;
  
      public void setName(String name) {
          this.name = name;
          nameLabel.setText(name);
      }
  
      public void setClickable(boolean b){
          playButton.setEnabled(b);
      }
  
      public void setPlaybuttonIcon(String s){
          ImageIcon icon = new ImageIcon(System.getProperty("user.dir") + "\\ressources\\playbutton.png");
          Image img = icon.getImage();
          Image scaledImg = img.getScaledInstance(16, 16, java.awt.Image.SCALE_SMOOTH);
          icon = new ImageIcon(scaledImg);
  
  
          ImageIcon icon2 = new ImageIcon(System.getProperty("user.dir") + "\\ressources\\pausebutton.png");
          Image img2 = icon2.getImage();
          Image scaledImg2 = img2.getScaledInstance(16, 16, java.awt.Image.SCALE_SMOOTH);
          icon2 = new ImageIcon(scaledImg2);
  
          if(s.equals("play")){
              playButton.setIcon(icon);
          }else{
              playButton.setIcon(icon2);
          }
      }
  
      public void setButton(String s) {
  
          if (s.equals("passed")) {
              ImageIcon icon = new ImageIcon(System.getProperty("user.dir") + "\\ressources\\check.png");
              Image img = icon.getImage();
              icon = new ImageIcon(img);
              statusIconLabel.setIcon(icon);
              statusIconLabel.setOpaque(false);
  
          } else if (s.equals("failed")) {
              ImageIcon icon = new ImageIcon(System.getProperty("user.dir") + "\\ressources\\fail.png");
              Image img = icon.getImage();
              icon = new ImageIcon(img);
              statusIconLabel.setIcon(icon);
              statusIconLabel.setOpaque(false);
  
          } else {
              ImageIcon icon = new ImageIcon(System.getProperty("user.dir") + "\\ressources\\help.png");
              Image img = icon.getImage();
              icon = new ImageIcon(img);
              statusIconLabel.setIcon(icon);
              statusIconLabel.setOpaque(false);
  
          }
      }
  
      public TestcasePanel() {
          super();
          setOpaque(true);
  
          playButton.setFocusable(false);
          playButton.setRolloverEnabled(false);
          GridBagLayout gbl = new GridBagLayout();
          GridBagConstraints gbc = new GridBagConstraints();
          this.setLayout(gbl);
          gbc.gridx = 0;
          gbc.gridy = 0;
          gbc.weightx = 0;
          gbc.insets = new Insets(3, 3, 3, 3);
          gbc.anchor = GridBagConstraints.WEST;
          gbl.setConstraints(statusIconLabel, gbc);
          this.add(statusIconLabel);
  
          gbc.gridx = 1;
          gbc.gridy = 0;
          gbc.weightx = 0.8;
          gbl.setConstraints(nameLabel, gbc);
          this.add(nameLabel);
  
          ImageIcon icon = new ImageIcon(System.getProperty("user.dir") + "\\ressources\\playbutton.png");
          Image img = icon.getImage();
          Image scaledImg = img.getScaledInstance(Integer.valueOf((int) this.getPreferredSize().getHeight()).intValue(),
                  Integer.valueOf((int) this.getPreferredSize().getHeight()).intValue(), java.awt.Image.SCALE_SMOOTH);
          icon = new ImageIcon(scaledImg);
          playButton.setName("play");
          playButton.setIcon(icon);
          gbc.gridx = 2;
          gbc.gridy = 0;
          gbc.weightx = 0;
          gbl.setConstraints(playButton, gbc);
          this.add(playButton);
  
      }
  
      public void setButtonIcon(String name){
  
          if(name.equals("play")){
              ImageIcon icon = new ImageIcon(System.getProperty("user.dir") + "\\ressources\\playbutton.png");
              Image img = icon.getImage();
              Image scaledImg = img.getScaledInstance(16,16, java.awt.Image.SCALE_SMOOTH);
              icon = new ImageIcon(scaledImg);
              playButton.setIcon(icon);
  
  
          }else if (name.equals("pause")) {
              ImageIcon icon = new ImageIcon(System.getProperty("user.dir") + "\\ressources\\pausebutton.png");
              Image img = icon.getImage();
              Image scaledImg =  img.getScaledInstance(16,16, java.awt.Image.SCALE_SMOOTH);
              icon = new ImageIcon(scaledImg);
              playButton.setIcon(icon);
  
  
          }
      }
  
  }
  </code></pre>
  
  <p>Thanks for any ideas.</p>