Java 使用GTK+降低JSlider的高度;外观
我想用LookAndFeel GTK降低JSlider的高度+ 可能吗 这里是更改LookAndFeel、Title和Classname的数组和方法Java 使用GTK+降低JSlider的高度;外观,java,gtk,height,look-and-feel,jslider,Java,Gtk,Height,Look And Feel,Jslider,我想用LookAndFeel GTK降低JSlider的高度+ 可能吗 这里是更改LookAndFeel、Title和Classname的数组和方法 public static boolean theLAF(String laf) { try { UIManager.setLookAndFeel(laf); UIManager.put("Slider.paintValue", false); return true; } catch (Clas
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
};
此附件仅适用于Linux
和主要方法
public static void main(String args[]) {
EventQueue.invokeLater(new Runnable() {
@Override public void run() {
final JFrame frame = new JFrame();
// frame.setUndecorated(true);
int n = 0;
for (String[] mLAF1 : mLAF) {
if (theLAF(mLAF1[1] /*Class LAF*/ )) {
JSlider jsl = new JSlider();
jsl.setMajorTickSpacing(20);
jsl.setMinorTickSpacing(5);
jsl.setPaintLabels(true);
jsl.setPaintTicks(true);
jsl.setSnapToTicks(true);
jsl.setToolTipText(mLAF1[0]);
JPanel jp = new JPanel();
jp.add(jsl);
Dimension d = jpVert.getPreferredSize();
jp.setMinimumSize(d);
jp.setSize(d);
JWindow win = createWindow(frame, jp, mLAF1[0] /*Title LAF*/, n);
n++;
}
}
JPanel jpMain = new JPanel();
jpMain.setBorder(BorderFactory.createLineBorder(new Color(255, 255, 255)));
jpMain.setBackground(new Color(0,0,0));
frame.getContentPane().add(jpMain, BorderLayout.CENTER);+
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
frame.setSize(1100, 200);
frame.setVisible(true);
}
});
}
我输入密码
public static void main(String args[]) {
EventQueue.invokeLater(new Runnable() {
@Override public void run() {
final JFrame frame = new JFrame();
// frame.setUndecorated(true);
int n = 0;
for (String[] mLAF1 : mLAF) {
if (theLAF(mLAF1[1] /*Class LAF*/ )) {
JSlider jsl = new JSlider();
jsl.setMajorTickSpacing(20);
jsl.setMinorTickSpacing(5);
jsl.setPaintLabels(true);
jsl.setPaintTicks(true);
jsl.setSnapToTicks(true);
jsl.setToolTipText(mLAF1[0]);
JPanel jp = new JPanel();
jp.add(jsl);
Dimension d = jpVert.getPreferredSize();
jp.setMinimumSize(d);
jp.setSize(d);
JWindow win = createWindow(frame, jp, mLAF1[0] /*Title LAF*/, n);
n++;
}
}
JPanel jpMain = new JPanel();
jpMain.setBorder(BorderFactory.createLineBorder(new Color(255, 255, 255)));
jpMain.setBackground(new Color(0,0,0));
frame.getContentPane().add(jpMain, BorderLayout.CENTER);+
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
frame.setSize(1100, 200);
frame.setVisible(true);
}
});
}