views:

407

answers:

1

The knob on vertical JSlider's on my Windows 7 machine (with native look-and-feel) is really, really tiny in both directions. Not just skinny but short as well. alt text

Can anyone confirm this? Should I report it? If so, where? Thanks!

Here is the code for the sample program (in the screen shot):

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JSlider;
import javax.swing.SwingConstants;
import javax.swing.UIManager;


public class SliderTest
{
    public static void main( String[] args )
    {
        // Set the look and feel to that of the system
        try
        { UIManager.setLookAndFeel( UIManager.getSystemLookAndFeelClassName() ); }
        catch ( Exception e )
        { System.err.println( e ); }


        // Launch the GUI from the event dispatch thread
        javax.swing.SwingUtilities.invokeLater( new Runnable()
        {
            public void run ()
            {
                JFrame window = new JFrame();
                window.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );

                JPanel contentPane = new JPanel();
                contentPane.add( new JSlider(SwingConstants.HORIZONTAL) );
                contentPane.add( new JSlider(SwingConstants.VERTICAL) );

                window.setContentPane( contentPane );
                window.pack();
                window.setLocationRelativeTo( null ); // Center window
                window.setVisible( true );
            }
        });
    }
}
+1  A: 

First off, this happens in Windows Vista too. It seems to be the case, that the slider tries to take as little space as possible. If you want a bigger JSlider use JSlider.setPaintTicks. So you have to add the following:

JSlider vertical = new JSlider( SwingConstants.VERTICAL );
vertical.setPaintTicks( true );
contentPane.add( vertical );

That should do the trick.

ablaeul