Bonjour à tous,
Je débute plus ou moins en java et pour m’exercer je tente de créer une calculatrice (original ? non ?… non ). C’est la deuxième que je fais, la première utilisais une classe rassemblant les constantes, pour celle–ci je souhaite passer par un PropertyResourceBundle et donc par un fichier .properties seulement voila, j’ai un problème les touches de ma calculatrice sont vide de texte (mais pas que les touches au final…).

Grâce au debug j’ai localisé le problème dans ma classe Parametrage, qui fait appel au PropertyResourceBundle qui ne me retourne pas toutes les valeurs demandées (marqué en commentaires dans le code) mais à partir de là je bloque… ben oui il me ramène certains des paramètres correctement (donc ça ne vient pas des méthodes getConstanteXxx(String)) ni du nom des variables ou des String qui les références (enfin je pense…).

Donc voilà, si quelqu’un voit la solution à mon problème (à force d’être le nez collé sur son code on voit moins bien ses erreurs )

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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
 
package net.lilk.calc.parametrage;
 
import java.util.PropertyResourceBundle;
import java.util.ResourceBundle;
 
public class Parametrage {
 
	private static final PropertyResourceBundle propertyResourceBundle = (PropertyResourceBundle) ResourceBundle
			.getBundle("parametres");
 
	public static final int LARGEUR = getConstanteInt("LARGEUR");
	public static final int HAUTEUR = getConstanteInt("HAUTEUR");
	public static final boolean RESIZABLE = getConstanteBoolean("RESIZABLE");
	public static final int ACTION_CLOSE = getConstanteInt("DEFAULT_ACTION_CLOSE");
	public static final String FENETRE = getConstanteString("TITRE_FENETRE_PRINCIPALE");
	public static final String ONGLETS = getConstanteString("NOM_TABBED_PANE1"); //retourne null
	public static final String NOM_ONGLET_1 = getConstanteString("NOM_ONGLET_1"); //retourne null
	public static final String CHAMP_PRINCIPAL = getConstanteString("NOM_TEXTFIELD1");
	public static final String BOUTON0 = getConstanteString("BOUTON0"); //retourne null
	public static final String BOUTON1 = getConstanteString("BOUTON1"); //retourne null
	public static final String BOUTON2 = getConstanteString("BOUTON2"); //retourne null
	public static final String BOUTON3 = getConstanteString("BOUTON3"); //retourne null
	public static final String BOUTON4 = getConstanteString("BOUTON4"); //retourne null
	public static final String BOUTON5 = getConstanteString("BOUTON5"); //retourne null
	public static final String BOUTON6 = getConstanteString("BOUTON6"); //retourne null
	public static final String BOUTON7 = getConstanteString("BOUTON7"); //retourne null
	public static final String BOUTON8 = getConstanteString("BOUTON8"); //retourne null
	public static final String BOUTON9 = getConstanteString("BOUTON9"); //retourne null
	public static final String BOUTON_DIV = getConstanteString("BOUTON_DIV"); //retourne null
	public static final String BOUTON_PLUS = getConstanteString("BOUTON_PLUS"); //retourne null
	public static final String BOUTON_MOINS = getConstanteString("BOUTON_MOINS"); //retourne null
	public static final String BOUTON_MULT = getConstanteString("BOUTON_MULT"); //retourne null
	public static final String BOUTON_EGAL = getConstanteString("BOUTON_EGAL"); //retourne null
	public static final String ICONE1 = getConstanteString("CHEMIN_ICO_CALC"); 
	public static final String OPERATEUR = getConstanteString("NOM_LABEL1");
	public static final String MENU_FICHIER = getConstanteString("MENU_FICHIER");
	public static final String[] SOUS_MENU_FICHIER = getConstanteStringTab("SOUS_MENU_FICHIER");
 
 
 
 
	private static Parametrage parametrage;
 
	private Parametrage() {
		super();
		// TODO Auto-generated constructor stub
	}
 
	public static Parametrage getInstance(){
		if (parametrage == null){
			parametrage = new Parametrage();
		}
		return parametrage;
	}
 
	private static int getConstanteInt(String string) {
		int valeur = Integer.parseInt((String) propertyResourceBundle
				.handleGetObject(string));
		return valeur;
	}
 
	private static boolean getConstanteBoolean(String string) {
		boolean valeur = Boolean.parseBoolean((String) propertyResourceBundle
				.handleGetObject(string));
		return valeur;
	}
 
	private static String getConstanteString(String string) {
		String valeur = (String) propertyResourceBundle.handleGetObject(string);
		return valeur;
	}
 
	private static String[] getConstanteStringTab(String string) {
		String valeurs = (String) propertyResourceBundle
				.handleGetObject(string);
		String[] liste = valeurs.split("\\|");
		return liste;
	}
}
Le fichier parametres.properties :
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
 
# Config de la fenetre
LARGEUR = 300
HAUTEUR = 300
RESIZABLE = true
 
# DO_NOTHING_ON_CLOSE = 0
# HIDE_ON_CLOSE = 1
# DISPOSE_ON_CLOSE = 2
# EXIT_ON_CLOSE = 3
DEFAULT_ACTION_CLOSE = 2
 
# nom de composant
TITRE_FENETRE_PRINCIPALE = Application
CALCUL_BOUTON = Calcul
NOM_BOUTON1 = bouton1
NOM_TEXTFIELD1 = textField1
NOM_TEXTFIELD2 = textField2
NOM_LABEL1 = operateur
NOM_LABEL2 = label2
NOM_JTEXTAREA1 = jTextArea1
NOM_SCROLLPANE1 = scrollPane1
NOM_COMBOBOX1 = comboBox1
NOM_TABBED_PANE1 = onglets
NOM_ONGLET_1 = Calculatrice
NOM_ONGLET2 = Autres
 
# Utiliser "separateur" pour introduire une ligne de séparation dans le sous menu
MENU_FICHIER = Fichier
SOUS_MENU_FICHIER = Nouveau|Ouvrir|Sauver|separateur|Quitter|
 
# BOUTONS
BOUTON0 = 0
BOUTON1 = 1
BOUTON2 = 2
BOUTON3 = 3
BOUTON4 = 4
BOUTON5 = 5
BOUTON6 = 3
BOUTON7 = 7
BOUTON8 = 8
BOUTON9 = 9
BOUTON_DIV = /
BOUTON_PLUS = +
BOUTON_MOINS = -
BOUTON_MULT = x
BOUTON_EGAL = =
 
 
# chemin vers les images
CHEMIN_ICO_CALC = ../WEB-INF/images/calculator.gif
CHEMIN_ICO_GEEK = WEB-INF/images/geekmodif2.gif
Je vous remercie d’avance,

JavaLilk