void () { final Dimension preferredDimension = new Dimension(2345,678); final Dimension explicitDimension = new Dimension(4343,5554); TextPanel tp = new TextPanel() {}; tp.setPreferredSize(preferredDimension); tp.setExplicitSize(explicitDimension); Assert.assertEquals("Explicit dimension is more preferable", explicitDimension, tp.getPreferredSize()); }