FontMetrics fm = cb.getFontMetrics(cb.getFont());
// the following width calculation is a guess. We know the value
// depends on the font size, and that it is relatively small, so after
// trying out a few candidates this one seems to give the right result
int width = fm.charWidth(' ') + additionalWidth;
int height = fm.getHeight() + additionalHeight;
harness.check(ui.getDefaultSize(), new Dimension(width, height));
cb.setFont(new Font("Dialog", Font.PLAIN, 32));
fm = cb.getFontMetrics(cb.getFont());
width = fm.charWidth(' ') + additionalWidth;