int () { GridBagLayout layout = (GridBagLayout)getLayout(); Component sideComponent = null; GridBagConstraints sideComponentConstraints = null; boolean unsupportedLayout = false; for (Component component : getComponents()) { GridBagConstraints c = layout.getConstraints(component); if (c.gridx > 0) { if (sideComponent == null && c.gridy == 0) { sideComponent = component; sideComponentConstraints = c; } else { unsupportedLayout = true; } } } if (unsupportedLayout) { Logger.getInstance(LineTooltipRenderer.class).error("Unsupported tooltip layout"); } if (sideComponent == null) { return 0; } else { Insets insets = sideComponentConstraints.insets; return sideComponent.getPreferredSize().width + (insets == null ? 0 : insets.left + insets.right); } }