public Dimension minimumLayoutSize(Container c) { int width = 30; if (frame.isClosable()) { width += 21; } if (frame.isMaximizable()) { width += 16 + (frame.isClosable() ? 10 : 4); } if (frame.isIconifiable()) { width += 16 + (frame.isMaximizable() ? 2 : (frame.isClosable() ? 10 : 4)); } FontMetrics fm = getFontMetrics(getFont()); String frameTitle = frame.getTitle(); int title_w = frameTitle != null ? fm.stringWidth(frameTitle) : 0; int title_length = frameTitle != null ? frameTitle.length() : 0; if (title_length > 2) { int subtitle_w = fm.stringWidth(frame.getTitle().substring(0, 2) + "..."); width += (title_w < subtitle_w) ? title_w : subtitle_w; } else { width += title_w; } int height = paletteTitleHeight; if (!isPalette) { int fontHeight = fm.getHeight() + 7; Icon icon = frame.getFrameIcon(); int iconHeight = 0; if (icon != null) { iconHeight = Math.min(icon.getIconHeight(), 18); } iconHeight += 5; height = Math.max(fontHeight, iconHeight); } return new Dimension(width, height); }