Bonjour à tous,

J'ai un soucis avec Nimbus et plus particulièrement l'utilisation des sizeVariant sur certains composants. Je voulais une JScrollBar en "mini" mais ça ne marche pas. Pourtant, Laffy affiche correctement les JScrollBar en mini. Est-ce que quelqu'un sait si il y a quelque chose à faire de plus que putClientProperty("JComponent.sizeVariant", "mini") ?

Le bout de code ci-dessous montre que le putClientProperty() est bien pris en compte pour une JProgressBar, à moitié pour un JButton (seul le texte est en mini) et pas du tout pour la JScrollBar.

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import java.awt.BorderLayout;
 
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JProgressBar;
import javax.swing.JScrollBar;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
import javax.swing.WindowConstants;
import javax.swing.UIManager.LookAndFeelInfo;
 
public class SizeVariantTest {
 
	public static void main(String args[]) throws Exception {
		SwingUtilities.invokeAndWait(new Runnable() {
			public void run() {
				try {
					for (LookAndFeelInfo info : UIManager
							.getInstalledLookAndFeels()) {
						if ("Nimbus".equals(info.getName())) {
							UIManager.setLookAndFeel(info.getClassName());
							break;
						}
					}
				} catch (UnsupportedLookAndFeelException e) {
					// handle exception
				} catch (ClassNotFoundException e) {
					// handle exception
				} catch (InstantiationException e) {
					// handle exception
				} catch (IllegalAccessException e) {
					// handle exception
				}
 
				JFrame frame = new JFrame("Size Variant test");
				frame.getContentPane().setLayout(new BorderLayout());
                               frame.setDefaultCloseOperation(
                                                            WindowConstants.EXIT_ON_CLOSE);
 
				JScrollBar scrollBar = new JScrollBar(JScrollBar.HORIZONTAL);
				scrollBar.putClientProperty("JComponent.sizeVariant", "mini");
 
				JButton button = new JButton("Press me");
				button.putClientProperty("JComponent.sizeVariant", "mini");
 
				JProgressBar progressBar = new JProgressBar();
				progressBar.putClientProperty("JComponent.sizeVariant", "mini");
				progressBar.setValue(50);
 
				frame.getContentPane().add(progressBar, BorderLayout.NORTH);
				frame.getContentPane().add(button, BorderLayout.CENTER);
				frame.getContentPane().add(scrollBar, BorderLayout.SOUTH);
 
				frame.pack();
				frame.setVisible(true);
			}
		});
	}
}
Testé sous Linux avec JRE 1.6.0_10 et 1.6.0_11, et sous XP avec JRE 1.6.0_11, sans succés.
Des idées ?