question: protected void updateChartLayout ( ) { chartContainer . removeAll ( ) ; List < String > selectedMetrics = getSelectedMetrics ( ) ; if ( selectedMetrics . size ( ) > 0 ) { if ( selectedMetrics . size ( ) <= 1 ) { chartContainer . setLayout ( new GridLayout ( 1 , 1 ) ) ; } else if ( selectedMetrics . size ( ) <= 2 ) { chartContainer . setLayout ( new GridLayout ( 2 , 1 ) ) ; } else if ( selectedMetrics . size ( ) <= 4 ) { chartContainer . setLayout ( new GridLayout ( 2 , 2 ) ) ; } else if ( selectedMetrics . size ( ) <= 6 ) { chartContainer . setLayout ( new GridLayout ( 3 , 2 ) ) ; } else { chartContainer . setLayout ( new GridLayout ( ( int ) Math . ceil ( selectedMetrics . size ( ) / 3.0 ) , 3 ) ) ; } GridLayout layout = ( GridLayout ) chartContainer . getLayout ( ) ; int spaces = layout . getRows ( ) * layout . getColumns ( ) ; for ( int i = 0 ; i < Math . max ( spaces , selectedMetrics . size ( ) ) ; i ++ ) { if ( i < selectedMetrics . size ( ) ) { chartContainer . add ( createChart ( selectedMetrics . get ( i ) ) ) ; } else { chartContainer . add ( new EmptyPlot ( this ) ) ; } } } chartContainer . revalidate ( ) ; }
target:  Updates the chart layout when the user changes which metrics to plot. This method must only be invoked on the event dispatch thread.