ItemAndWidth (ItemAndWidth current, String candidate) { int width = myTable.getFontMetrics(myTable.getFont()).stringWidth(candidate); if (width > current.myWidth) { return new ItemAndWidth(candidate, width); } return current; }