Dimension () { Dimension dimension = new Dimension(); for (Icon each : icons) { dimension.width = Math.max(each.getIconWidth(), dimension.width); dimension.height = Math.max(each.getIconHeight(), dimension.height); } return new Dimension(Math.max(passiveIcon.getIconWidth(), dimension.width), Math.max(passiveIcon.getIconHeight(), dimension.height)); }