使用GTK + LookAndFeel降低JSlider的高度

时间:2016-12-12 16:24:53

标签: java gtk height look-and-feel jslider

我想用LookAndFeel GTK +

来减少JSlider高度

有可能吗?

enter image description here

error

这里是更改LookAndFeel,Title和Classname的数组和方法。

  public static JWindow createWindow(JFrame frame, Container container, String sTitle, int n) {
    return new SelfInternalWindow(frame, container, sTitle, n);
  }

  static class SelfInternalWindow extends JWindow {
    SelfInternalWindow(JFrame frame, Container container, String sTitle, int n) {
      super(frame);
      add(container, "Center");
      Dimension d = container.getPreferredSize();
      setSize(d);
      int posx = 10 + 206*n;
      int posy = 80;
      setLocation(posx, posy);  //Moves this component to a new location.
      setVisible(true);
      pack();
      JLabel jLab = new JLabel(sTitle);
      jLab.setBackground(new Color(200, 200, 200, 128));
      JWindow jwin = new JWindow(frame);
      jwin.add(jLab, BorderLayout.CENTER);
      jwin.setSize(jLab.getPreferredSize().width, jLab.getPreferredSize().height);
      jwin.setLocation(posx, posy -jLab.getPreferredSize().height - 2);
      jwin.setVisible(true);
    }
  }

这个anippet仅适用于Linux!

主要方法!

  public static boolean theLAF(String laf) {
    try {
     UIManager.setLookAndFeel(laf);
     UIManager.put("Slider.paintValue", false);
     return true;
    } catch (ClassNotFoundException | InstantiationException | 
      IllegalAccessException | UnsupportedLookAndFeelException e) {
      return false;
    }
  }

  static String[][] mLAF = new String [][] {
    { "GTK+" /*Title LAF*/, "com.sun.java.swing.plaf.gtk.GTKLookAndFeel"  /*Class*/}
    // Another LAF
  };

我把代码放了。

0 个答案:

没有答案