JSlider 隐藏 GTK+ 和 Nimbus LookAndFeel 的价值 Linux

JSlider hidding Value for GTK+ and Nimbus LookAndFeel On Linux

我有这种情况(JSlider 在不需要时显示值)。而且我不想在 JSlider 上显示当前值。

  1. 为什么只有 Linux 显示使用 LookAndFeel Nimbus 和 GTK+ 的 JSlider 中的值?
  2. 如何隐藏这个值?

显示下一张图片 运行 Windows 10、Cent OS 7 和 MacOS Sierra

上的代码

这是我的代码:

import java.awt.BorderLayout;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.EventQueue;
import javax.swing.Box;
import javax.swing.BoxLayout;

import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JSlider;

import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;

public class JSliderLAF {

  public static void changeLAF(Container container, String laf) {
    try {
      UIManager.setLookAndFeel(laf);
    } catch (ClassNotFoundException | InstantiationException | 
        IllegalAccessException | UnsupportedLookAndFeelException e) {
    }
    SwingUtilities.updateComponentTreeUI(container);
  }

  public static void main(String args[]) {
    EventQueue.invokeLater(() -> {
      JPanel jpVert = new JPanel();
      jpVert.setLayout(new BoxLayout(jpVert, BoxLayout.PAGE_AXIS));
      for (UIManager.LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
        JSlider jsl = new JSlider();
        jsl.setMajorTickSpacing(20);
        jsl.setMinorTickSpacing(5);
        jsl.setPaintLabels(true);
        jsl.setPaintTicks(true);
        jsl.setSnapToTicks(true);
        JPanel jpHorz = new JPanel();
        jpHorz.setLayout(new BoxLayout(jpHorz, BoxLayout.LINE_AXIS));
        JLabel jlName = new JLabel(info.getName() + " : ");
        JLabel jlClass = new JLabel(info.getClassName());
        jpHorz.add(jsl);
        jpHorz.add(Box.createRigidArea(new Dimension(5,0)));
        jpHorz.add(jlName);
        jpHorz.add(Box.createRigidArea(new Dimension(2,0)));
        jpHorz.add(jlClass);
        jpHorz.add(Box.createRigidArea(new Dimension(2,0)));
        jpHorz.add(Box.createHorizontalGlue());
        changeLAF(jsl,info.getClassName());
        jpVert.add(jpHorz);
      }
      final JFrame frame = new JFrame();
      frame.add(jpVert, BorderLayout.NORTH);
      frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
      frame.pack();
      frame.setVisible(true);
    });
  }        
}
public static void changeLAF(Container container, String laf) {
  try {
    UIManager.setLookAndFeel(laf);
    UIManager.put("Slider.paintValue", false);
  } catch (ClassNotFoundException | InstantiationException | 
      IllegalAccessException | UnsupportedLookAndFeelException e) {
  }
  SwingUtilities.updateComponentTreeUI(container);
}