private void setSizeOfWeekNumberLabels ( ) { JLabel firstLabel = weekNumberLabels . get ( 0 ) ; Font font = firstLabel . getFont ( ) ; FontMetrics fontMetrics = firstLabel . getFontMetrics ( font ) ; int width = fontMetrics . stringWidth ( "53 " ) ; width += constantWeekNumberLabelInsets . left ; width += constantWeekNumberLabelInsets . right ; Dimension size = new Dimension ( width , 1 ) ; for ( JLabel currentLabel : weekNumberLabels ) { currentLabel . setMinimumSize ( size ) ; currentLabel . setPreferredSize ( size ) ; } topLeftLabel . setMinimumSize ( size ) ; topLeftLabel . setPreferredSize ( size ) ; }
setSizeOfWeekNumberLabels This sets the minimum and preferred size of the week number labels to be able to hold largest week number in the current week number label font .