Hello,

Je débute en Swing... mon problème est sûrement plus général que juste lié aux ComboBoxes, mais je le mets là, libre à vous de le déplacer ailleurs.

Bref, voilà mon soucis :
- j'ai une ComboBox disabled
- j'ai forcé la propriété ComboBox.disabledBackground à RED
- sous Windows Vista, avec le thème "Windows Vista Basic" la combo n'est pas RED
- sous Windows Vista, avec tous les autres thèmes, la combo est bien rouge !

donc... heu ?!?

le code :

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
 
import java.awt.Color;
import java.awt.FlowLayout;
 
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
 
public class ComboVista extends JFrame  {
 
	private JComboBox box;
 
	public static void main(String[] args) throws ClassNotFoundException, InstantiationException, IllegalAccessException, UnsupportedLookAndFeelException {
 
		UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
 
		UIManager.getDefaults().put( "ComboBox.disabledBackground", Color.RED );
 
		SwingUtilities.invokeLater(new Runnable() {
			public void run() {
				ComboVista cv = new ComboVista();
				cv.setVisible(true);
			}
		});
	}
 
	public ComboVista() {
		super();
		build();
	}
 
	public void build() {
		setTitle("Test Combo & Vista"); 
		setSize(250, 70);
		setLocationRelativeTo(null); 
		setResizable(false);
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 
		setContentPane(buildContentPane());
	}
 
	private JPanel buildContentPane() {
 
		JPanel panel = new JPanel();
		panel.setLayout(new FlowLayout(FlowLayout.LEFT));
 
		box = new JComboBox() ;
		box.addItem("disabled") ;
		box.setEnabled(false) ;
		panel.add(box) ;	
 
		return panel;
 
	}
 
 
}

résultat sous Windows Vista avec le thème "Windows Standard" :


résultat sous Windows Vista avec le thème "Windows Vista Basic" :



Et la question est évidemment : comment faire pour que ça marche aussi avec le thème Vista ?!?

Merci.