Ouattara Idriss
Messages postés3Date d'inscriptionjeudi 7 décembre 2006StatutMembreDernière intervention 5 juin 2010
-
15 oct. 2008 à 13:25
Ombitious_Developper
Messages postés2333Date d'inscriptionsamedi 28 février 2004StatutMembreDernière intervention26 juillet 2013
-
17 oct. 2008 à 08:47
J'ai développé une appli MDI avec java qui tourne assez bien. Mais j'ai un problème. J'utilise des JInternal Frames dans ma MDI. Je voudrais savoir comment activer ou désactiver les icônes et certains sous-menus de la feuille principale à chaque appel d'une feuille fille afin de ne pas permettre à l'utilisateur de clicker sur les icône et menu de la feuille principale lorsqu'une une JinternalFrame est affichée?
Merci pour votre aide
Ombitious_Developper
Messages postés2333Date d'inscriptionsamedi 28 février 2004StatutMembreDernière intervention26 juillet 201339 15 oct. 2008 à 17:44
Salut:
Une idée simpliste c'est d'identifier d'une façon unique les JInternalFrames par exemple avec un identifiant, dans une première étape.
Dans une seconde étape, il faut faire un petit test avant d'afficher un JInternalFrame donné:
S'il n'existe pas on l'affiche, sinon on ne fait rien.
La méthode JDesktopPane::getAllFrames() retroune toutes les JInternalFrames qui sont actuellement affichées.
Il y a plusieurs façons pour identifier un JInternalFrame:
1. Par son titre.
2. Par un identifiant unique.
Voici comment identifier un JInternalFrame avec un code unique.
public class UIDGenerator {
private static int value = -1;
public static int getUID() {
value++;
return value;
}
}
// Supposons qu'on a deux classes JInternalFrame
public class JInternalFrameOne extends JInternalFrame {
private static final int UID = UIDGenerator.getUID();
public JInternalFrameOne() {
// Il faut appeler cette méthode dans tous les constructeurs de cette classe
// Ici, j'ai supposé qu'on a un seul constructeur avec zéro argument
setClientProperty("UID", UID);
}
}
public class JInternalFrameTwo extends JInternalFrame {
private static final int UID = UIDGenerator.getUID();
public JInternalFrameTwo() {
// Il faut appeler cette méthode dans tous les constructeurs de cette classe
// Ici, j'ai supposé qu'on a un seul constructeur avec zéro argument
setClientProperty("UID", UID);
}
}
// Une méthode de test
public boolean check(JDesktopPane desktop, JInternalFrame frame) {
Integer uid = (Integer)frame.getClientProperty("UID");
if (uid == null) {
throw new UnsupportedOperationException("UID Property Not Found.");
}
for (JInternalFrame f : desktop.getAllFrames()) {
Integer otherUID = (Integer)frame.getClientProperty("UID");
if (otherUID == null) {
throw new UnsupportedOperationException("UID Property Not Found.");
Ombitious_Developper
Messages postés2333Date d'inscriptionsamedi 28 février 2004StatutMembreDernière intervention26 juillet 201339 15 oct. 2008 à 17:46
Salut:
Petite correction:
public boolean check(JDesktopPane desktop, JInternalFrame frame) {
Integer uid = (Integer)frame.getClientProperty("UID");
if (uid == null) {
throw new UnsupportedOperationException("UID Property Not Found.");
}
for (JInternalFrame f : desktop.getAllFrames()) {
Integer otherUID = (Integer)f.getClientProperty("UID");
if (otherUID == null) {
throw new UnsupportedOperationException("UID Property Not Found.");
}
if (uid.equals(otherUID)) {
return true;
}
}
return false;
}
Ombitious_Developper
Messages postés2333Date d'inscriptionsamedi 28 février 2004StatutMembreDernière intervention26 juillet 201339 17 oct. 2008 à 08:46
Salut:
Petite correction:
// Supposons qu'on a deux classes JInternalFrame
public class JInternalFrameOne extends JInternalFrame {
private static final int UID = UIDGenerator.getUID();
public JInternalFrameOne() {
// Il faut appeler cette méthode dans tous les constructeurs de cette classe
// Ici, j'ai supposé qu'on a un seul constructeur avec zéro argument
putClientProperty("UID", UID);
}
}
public class JInternalFrameTwo extends JInternalFrame {
private static final int UID = UIDGenerator.getUID();
public JInternalFrameTwo() {
// Il faut appeler cette méthode dans tous les constructeurs de cette classe
// Ici, j'ai supposé qu'on a un seul constructeur avec zéro argument
putClientProperty("UID", UID);
}
}
public boolean check(JDesktopPane desktop, JInternalFrame frame) {
Integer uid = (Integer)frame.getClientProperty("UID");
if (uid == null) {
throw new UnsupportedOperationException("UID Property Not Found.");
}
for (JInternalFrame f : desktop.getAllFrames()) {
Integer otherUID = (Integer)f.getClientProperty("UID");
if (otherUID == null) {
throw new UnsupportedOperationException("UID Property Not Found.");
}
if (uid.equals(otherUID)) {
return true;
}
}
return false;
}
Ombitious_Developper
Messages postés2333Date d'inscriptionsamedi 28 février 2004StatutMembreDernière intervention26 juillet 201339 17 oct. 2008 à 08:47