if(this.getComponentCount() > 1) { remove(selIndex); }
remove(selIndex);
	private void processMouseEvents(MouseEvent e) {		int tabNumber = getUI().tabForCoordinate(this, e.getX(), e.getY());		if (tabNumber < 0) return;		boolean otherWasOver = false;		for (int i=0; i<getTabCount(); i++) {			if (i != tabNumber) {				CloseIcon ic = (CloseIcon) getIconAt(i);				if (ic != null) {					if (ic.mouseover)						otherWasOver = true;					ic.mouseover = false;				}			}		}		if (otherWasOver)			repaint();		CloseIcon icon = (CloseIcon) getIconAt(tabNumber);		if (icon != null) {			Rectangle rect = icon.getBounds();			boolean vpIsNull = headerViewport == null;			Point pos = vpIsNull ? new Point() : headerViewport.getViewPosition();			int vpDiffX = (vpIsNull ? 0 : headerViewport.getX());			int vpDiffY = (vpIsNull ? 0 : headerViewport.getY());			Rectangle drawRect = new Rectangle(rect.x - pos.x + vpDiffX,					rect.y - pos.y + vpDiffY, rect.width, rect.height);						if (e.getID() == e.MOUSE_PRESSED) {				icon.mousepressed = e.getModifiers() == e.BUTTON1_MASK;				repaint(drawRect);			} else if (e.getID() == e.MOUSE_MOVED || e.getID() == e.MOUSE_DRAGGED ||					e.getID() == e.MOUSE_CLICKED) {				pos.x += e.getX() - vpDiffX;				pos.y += e.getY() - vpDiffY;				if (rect.contains(pos)) {					if (e.getID() == e.MOUSE_CLICKED) {						int selIndex = getSelectedIndex();						if (fireCloseTab(selIndex)) {							if (selIndex > 0) {								// to prevent uncatchable null-pointers								Rectangle rec = getUI().getTabBounds(this, selIndex - 1);																MouseEvent event = new MouseEvent((Component) e.getSource(),										e.getID() + 1,										System.currentTimeMillis(),										e.getModifiers(),										rec.x,										rec.y,										e.getClickCount(),										e.isPopupTrigger(),										e.getButton());								dispatchEvent(event);							}							//the tab is being closed							if(this.getComponentCount() > 1) {								remove(selIndex);							}						} else {							icon.mouseover = false;							icon.mousepressed = false;							repaint(drawRect);						}					} else {						icon.mouseover = true;						icon.mousepressed = e.getModifiers() == e.BUTTON1_MASK;					}				} else {					icon.mouseover = false;				}				repaint(drawRect);			}		}	}