Dimension () { // This trick makes text component to carry text over to the next line // if the text line width exceeds parent's width Dimension dimension = super.getPreferredSize(); dimension.width = 0; return dimension; }