2017-09-18 11 views
0

J'ai un problème avec une zone de liste déroulante, je ne peux pas afficher les données dans le combo, je dois faire un clic droit avant un clic gauche pour afficher mes données, mais avec juste un clic gauche c'est pas possible.Impossible d'afficher la liste déroulante

L'image ci-dessous montrent le premier cas (quand je fais un clic gauche)

The below image show the first case(when I do a left click).

L'image ci-dessous montre le second cas (quand je fais un clic droit avant le clic gauche)

this image show the second case(when I do a right click before the left click)

Merci pour avoir l'aide

+0

Vous devez ajouter plus d'informations afin que nous puissions vous aider à déboguer, comme un morceau de code, la fonction que vous utilisez pour gérer les clics, etc. –

Répondre

0
/** 
* Configure the renderer appropriately with the status of the 
* Drawing object. 
*/ 

composante publique getListCellRendererComponent (liste JList, Valeur de l'objet, int index, boolean isSelected, boolean cellHasFocus) { Composant theResult = super.getListCellRendererComponent (liste, valeur, index, isSelected, cellHasFocus); System.out.println ("theResult:" + theResult.toString()); System.out.println ("deb methode getLi classe AWICombo => valeur" + valeur + ", index" + index + ", isSélectionné" + isSelected + ", celhasFocus" + cellHasFocus); // crash de l'affichage dans la combo box avec jdk 1.3: setOpaque (true) résout le problème. // ((JComponent) theResult) .setOpaque (true); // setOpaque (true); if (index == -1) { System.out.println ("Dans si index == -1"); renvoyer theResult; } try { System.out.println ("Dans le bloc 1"); booléen notEmpty = false; AWCState theObjectToDisplay = null;

 try { 
      System.out.println("In try bloc 2"); 
      System.out.println("index " +index); 
      System.out.println("theModel call :" +theModel.toString()); 
      theObjectToDisplay = (AWCState) theModel.theComboValues.elementAt(index); 
      System.out.println("theObjectToDisplay => "+theObjectToDisplay.toString()); 
      System.out.println("dans conbobox "+index); 
     } catch (java.lang.ArrayIndexOutOfBoundsException aioobe) { 
     aioobe.printStackTrace(); 
     } 
     // test if the first square of the conbo box is empty for doen't set the tool tips 
     if (theObjectToDisplay != null) { 
      System.out.println("In if 1"); 
      if (theObjectToDisplay.toString() != null) { 
       System.out.println("In if 2"); 
       if (value.toString().compareTo(theObjectToDisplay.toString()) != 0) { 
        System.out.println("In if 3"); 
        if (value.toString().compareTo("") != 0) { 
         System.out.println("In if 4"); 
         theObjectToDisplay = (AWCState) theModel.theComboValues.elementAt(index - 1); 
         notEmpty = true; 
        } 
       } else { 
        System.out.println("In else 1"); 
        notEmpty = true; 
       } 
      } 
     } else { 
      System.out.println("In else 2"); 
      theObjectToDisplay = (AWCState) theModel.theComboValues.elementAt(index - 1); 
      notEmpty = true; 
     } 

     if (isSelected) { 
      System.out.println("In if isSelected "+list.getSelectionBackground()); 
      System.out.println("In if isSelected "+list.getSelectionForeground()); 
      setBackground(list.getSelectionBackground()); 
      setForeground(list.getSelectionForeground()); 
      setToolTip(list, notEmpty, theObjectToDisplay, value); 
     } else { 
      setBackground(list.getBackground()); 
      setForeground(list.getForeground()); 
     } 

     setFont(list.getFont()); 
     if (value == null) { 
      System.out.println("In if value == null"); 
     setText(""); 
     } 
     else { 
     setText(value.toString()); 
     } 

     // object is not obsolete 
     if (theObjectToDisplay == null || theObjectToDisplay.getStatus().equals(AWCConstants.OFFICIAL)) { 
      System.out.println("object is not obsolete theObjectToDisplay=>"+theObjectToDisplay.toString()); 
      return theResult; 
     } 



     // object is obsolete 
     if (index == 1) { 
      return theResult; 
     } 
     if (!isSelected) { 
      theResult.setBackground(Color.red); 
     } else { 
      theResult.setBackground(new Color(155, 100, 155)); 
     } 

    } 
    catch (NullPointerException npe) { 
     npe.printStackTrace(); 
    } 
    catch (java.lang.ArrayIndexOutOfBoundsException aioobe) { 
     aioobe.printStackTrace(); 
    } 
    System.out.println("end of function"); 
    return theResult; 

}