protected void revalidateLayout ( ) { for ( MaterialIcon icon : iconList ) { icon . removeFromParent ( ) ; } iconList . clear ( ) ; // same mouse-out handler for all icons MouseOutHandler outHandler = event -> { if ( ! isEnabled ( ) || ! isEditable ( ) ) { return ; } revalidateSelection ( currentRating ) ; } ; for ( int i = 0 ; i < maxRating ; i ++ ) { final int rating = i + 1 ; MaterialIcon icon = new MaterialIcon ( unselectedRatingIcon ) ; registerHandler ( icon . addClickHandler ( event -> { if ( ! isEnabled ( ) || ! isEditable ( ) ) { return ; } setValue ( rating , true ) ; } ) ) ; registerHandler ( icon . addMouseOverHandler ( event -> { if ( ! isEnabled ( ) || ! isEditable ( ) ) { return ; } revalidateSelection ( rating ) ; } ) ) ; registerHandler ( icon . addMouseOutHandler ( outHandler ) ) ; add ( icon ) ; iconList . add ( icon ) ; } revalidateSelection ( currentRating ) ; }
Method called internally by the component to re - validate the number of icons when the maximum rating is changed .