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

标签 java swing windows-7

我的 Windows 7 机器(具有 native 外观)上垂直 JSlider 的旋钮在两个方向上都非常非常小。不仅瘦还矮。 alt text

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

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

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 );
            }
        });
    }
}

最佳答案

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

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

这应该可以解决问题。

关于Windows 7 外观上的 Java Swing 渲染错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2754306/

相关文章:

java - 通过 Swing-java 实现数据库实体之间关系的 UI

c++ - 在 Windows 7 中记录不正确的密码

java - 正在验证 URI,位于重定向下方。网络应用程序 : Servlets Java

java - Angularjs/Java - 从休息服务方法获取图像

java - 如何在正在验证的 jTextField 上设置默认值?

Java PaintComponent 的大小和位置在扩展 Jpanel 的抽象类的子类中

c++ - 使用 RasDial 建立 VPN 连接后,是否要防止网络定位向导弹出?

performance - Windows 7 上的 Subversion 慢得让人难以忍受

java - 无法使用 iText Java 重命名 PDF 中的表单字段

java - 找到两个链表的交点?