if(tip != null) {
tip.hide();
tip = null;
}
if(text != null) {
PopupFactory popupFactory = PopupFactory.getSharedInstance();
JTextArea textContent = new JTextArea(text);
textContent.setFont(UIManager.getFont("ToolTip.font"));
textContent.setBackground(UIManager.getColor("ToolTip.background"));
textContent.setForeground(UIManager.getColor("ToolTip.foreground"));
textContent.setBorder(UIManager.getBorder("ToolTip.border"));
Point location = new Point(point);
SwingUtilities.convertPointToScreen(location, table.getParent());
GraphicsConfiguration gc = table.getGraphicsConfiguration();
Rectangle sBounds = gc.getBounds();
Insets screenInsets = Toolkit.getDefaultToolkit().getScreenInsets(gc);
sBounds.x += screenInsets.left;
sBounds.y += screenInsets.top;
sBounds.width -= screenInsets.left + screenInsets.right;
sBounds.height -= screenInsets.top + screenInsets.bottom;
Dimension tipSize = textContent.getPreferredSize();
// tipSize.height = Math.min(tipSize.height, 500);
textContent.setPreferredSize(tipSize);
location.x += 20;
location.x = Math.min(location.x, sBounds.x + sBounds.width - tipSize.width);
if(location.y + tipSize.height > sBounds.y + sBounds.height && location.y - 40 - tipSize.height >= sBounds.y) {
location.y -= 40 + tipSize.height;
}
location.y += 20;
tip = popupFactory.getPopup(null, textContent, location.x, location.y);
tip.show();
}
}
@Override
public void tableChanged(TableModelEvent e) {