Windows 7外观上的Java Swing渲染错误?

Vim*_*mes 8 java swing windows-7

我的Windows 7机器上的垂直JSlider上的旋钮(具有原生外观)在两个方向上真的很小.不仅是瘦,还有短.替代文字http://img101.imageshack.us/img101/8946/verticalsliderproblemwi.jpg

谁能证实这一点?我应该报告吗?如果是的话,在哪里?谢谢!

以下是示例程序的代码(在屏幕截图中):

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 );
            }
        });
    }
}
Run Code Online (Sandbox Code Playgroud)

abl*_*eul 4

首先,这种情况在 Windows Vista 中也会发生。情况似乎是这样,滑块试图占用尽可能少的空间。如果你想要更大的JSlider用途JSlider.setPaintTicks。所以你必须添加以下内容:

JSlider vertical = new JSlider( SwingConstants.VERTICAL );
vertical.setPaintTicks( true );
contentPane.add( vertical );
Run Code Online (Sandbox Code Playgroud)

这应该够了吧。