Program: 150528
Project: 150528
Buggy source:
private void addSQLEditorPane(DatabaseDescriptor databaseDescriptor){
  isAdjusting=true;
  int index=editorTabbedPane.getTabCount() - 1;
  final EditorPane sqlEditorPane=new EditorPane(databaseDescriptor);
  String title="String_Node_Str" + contextCount++;
  editorTabbedPane.insertTab(title,null,sqlEditorPane,null,index);
  final JPanel tabComponent=new JPanel(new BorderLayout());
  tabComponent.setOpaque(false);
  tabComponent.add(new JLabel(title),BorderLayout.CENTER);
  final JLabel closeLabel=new JLabel(new ImageIcon(getClass().getResource("String_Node_Str")));
  closeLabel.addMouseListener(new MouseAdapter(){
    @Override public void mouseReleased(    MouseEvent e){
      if (!closeLabel.contains(e.getPoint())) {
        return;
      }
      isAdjusting=true;
      if (editorTabbedPane.getTabCount() > 2) {
        for (int i=editorTabbedPane.getTabCount() - 1; i >= 0; i--) {
          if (editorTabbedPane.getTabComponentAt(i) == tabComponent) {
            ((EditorPane)editorTabbedPane.getComponentAt(i)).closeConnection();
            editorTabbedPane.removeTabAt(i);
            if (i == editorTabbedPane.getTabCount() - 1) {
              editorTabbedPane.setSelectedIndex(i - 1);
            }
            break;
          }
        }
      }
      isAdjusting=false;
    }
    @Override public void mouseEntered(    MouseEvent e){
      if (editorTabbedPane.getTabCount() > 2) {
        closeLabel.setIcon(new ImageIcon(getClass().getResource("String_Node_Str")));
      }
    }
    @Override public void mouseExited(    MouseEvent e){
      closeLabel.setIcon(new ImageIcon(getClass().getResource("String_Node_Str")));
    }
  }
);
  tabComponent.add(closeLabel,BorderLayout.EAST);
  editorTabbedPane.setTabComponentAt(index,tabComponent);
  editorTabbedPane.setSelectedIndex(index);
  isAdjusting=false;
  sqlEditorPane.adjustDefaultFocus();
}

Fixed version (ground truth):
private void addSQLEditorPane(DatabaseDescriptor databaseDescriptor){
  isAdjusting=true;
  int index=editorTabbedPane.getTabCount() - 1;
  final EditorPane sqlEditorPane=new EditorPane(databaseDescriptor);
  String title="String_Node_Str" + contextCount++;
  editorTabbedPane.insertTab(title,null,sqlEditorPane,null,index);
  final JPanel tabComponent=new JPanel(new BorderLayout());
  tabComponent.setOpaque(false);
  tabComponent.add(new JLabel(title),BorderLayout.CENTER);
  final JLabel closeLabel=new JLabel(new ImageIcon(getClass().getResource("String_Node_Str")));
  closeLabel.setBorder(BorderFactory.createEmptyBorder(0,2,0,0));
  closeLabel.addMouseListener(new MouseAdapter(){
    @Override public void mouseReleased(    MouseEvent e){
      if (!closeLabel.contains(e.getPoint())) {
        return;
      }
      isAdjusting=true;
      if (editorTabbedPane.getTabCount() > 2) {
        for (int i=editorTabbedPane.getTabCount() - 1; i >= 0; i--) {
          if (editorTabbedPane.getTabComponentAt(i) == tabComponent) {
            ((EditorPane)editorTabbedPane.getComponentAt(i)).closeConnection();
            editorTabbedPane.removeTabAt(i);
            if (i == editorTabbedPane.getTabCount() - 1) {
              editorTabbedPane.setSelectedIndex(i - 1);
            }
            break;
          }
        }
      }
      isAdjusting=false;
    }
    @Override public void mouseEntered(    MouseEvent e){
      if (editorTabbedPane.getTabCount() > 2) {
        closeLabel.setIcon(new ImageIcon(getClass().getResource("String_Node_Str")));
      }
    }
    @Override public void mouseExited(    MouseEvent e){
      closeLabel.setIcon(new ImageIcon(getClass().getResource("String_Node_Str")));
    }
  }
);
  editorTabbedPane.addChangeListener(new ChangeListener(){
    @Override public void stateChanged(    ChangeEvent e){
      int selectedIndex=editorTabbedPane.getSelectedIndex();
      Component tabComponent2=editorTabbedPane.getTabComponentAt(selectedIndex);
      closeLabel.setVisible(tabComponent2 == tabComponent && editorTabbedPane.getTabCount() > 2);
    }
  }
);
  tabComponent.add(closeLabel,BorderLayout.EAST);
  editorTabbedPane.setTabComponentAt(index,tabComponent);
  editorTabbedPane.setSelectedIndex(index);
  isAdjusting=false;
  sqlEditorPane.adjustDefaultFocus();
}