go to previous page   go to home page   go to next page

Answer:

sliderV = new JSlider( JSlider.VERTICAL,  
    0, 1000, 400);
sliderV.setMajorTickSpacing( 100 );
sliderV.setMinorTickSpacing(  50 );
sliderV.setPaintTicks ( true );
sliderV.setPaintLabels( true ); 

setPreferredSize()

Vertical Slider

The layout managers have control over the size of components, but often do their job better if you indicate a preferred size. This is done with

setPreferredSize( new Dimension( int width, int height ) )

If this is not used, the graphical representation of a slider often has its labels and tick marks crowded together.

QUESTION 7:

Suggest that this slider have a width of 50 and a height of 300:

sliderV.setPreferredSize( new Dimension(  , ) );