Dimension () { if (isPreferredSizeSet()) { Dimension setSize = getPreferredSize(); setPreferredSize(null); Dimension result = getPreferredSize(); setPreferredSize(setSize); return result; } return getPreferredSize(); }