private void changeOrientation(){
  if (mainPanel.getWidth() > mainPanel.getHeight()) {
    speedSlider.setOrientation(JSlider.HORIZONTAL);
    if (speedSliderContinuous != null) {
      speedSliderContinuous.setOrientation(JSlider.HORIZONTAL);
    }
    mainPanel.remove(buttonPanel);
    mainPanel.add(buttonPanel,BorderLayout.EAST);
  }
 else {
    speedSlider.setOrientation(JSlider.VERTICAL);
    if (speedSliderContinuous != null) {
      speedSliderContinuous.setOrientation(JSlider.VERTICAL);
    }
    mainPanel.remove(buttonPanel);
    mainPanel.add(buttonPanel,BorderLayout.SOUTH);
  }
}

private void changeOrientation ( ) { if ( mainPanel . getWidth ( ) > mainPanel . getHeight ( ) ) { speedSlider . setOrientation ( JSlider . HORIZONTAL ) ; if ( speedSliderContinuous != null ) { speedSliderContinuous . setOrientation ( JSlider . HORIZONTAL ) ; } mainPanel . remove ( buttonPanel ) ; mainPanel . add ( buttonPanel , BorderLayout . EAST ) ; } else { speedSlider . setOrientation ( JSlider . VERTICAL ) ; if ( speedSliderContinuous != null ) { speedSliderContinuous . setOrientation ( JSlider . VERTICAL ) ; } mainPanel . remove ( buttonPanel ) ; mainPanel . add ( buttonPanel , BorderLayout . SOUTH ) ; } }
the user has resized the frame . possibly change from horizontal to vertical layout .
