我想用LookAndFeel GTK +
来减少JSlider高度有可能吗?
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
};
我把代码放了。