• Martes 23 de Abril de 2024, 08:07

Autor Tema:  Re: Focustraversalpolicy Dudas  (Leído 2175 veces)

nicokiki

  • Miembro MUY activo
  • ***
  • Mensajes: 298
    • Ver Perfil
Re: Focustraversalpolicy Dudas
« en: Miércoles 21 de Julio de 2004, 16:45 »
0
Hola!!!!!!!

Implementé un FocusTraversalPolicy "sobrecargando" getComponentAfter, getComponentBefore, getDefaultComponent, getLastComponent, getFirstComponent.
El problema es que cuando el foco esta en uno de los JTextFields el metodo getComponentBefore no es llamado y no se por que es. El JTextField del problema se llama textoInstrumento. Ahi va algo de codigo:

Código: Text
  1.  
  2.   public class PoliticaFocos extends FocusTraversalPolicy
  3.   {
  4.     /**@param focusCycleRoot Raiz
  5.      * @param aComponent Componente
  6.      * @return Siguiente componente */
  7.     public Component getComponentAfter(Container focusCycleRoot,
  8.                                        Component aComponent)
  9.     {
  10.       if (aComponent.equals(textoInstrumento))
  11.         return textoPrecio;
  12.       if (aComponent.equals(textoPrecio))
  13.         return textoCliente;
  14.       if (aComponent.equals(textoCliente))
  15.         return textoCantidad;
  16.       if (aComponent.equals(textoCantidad))
  17.         return textoPosicion;
  18.       if (aComponent.equals(textoPosicion))
  19.         return textoCondicion;
  20.       if (aComponent.equals(textoCondicion))
  21.         return textoInstrumento;
  22.       return textoInstrumento;
  23.     }
  24.  
  25.     /**@param focusCycleRoot Raiz
  26.      * @param aComponent Componente
  27.      * @return Componente anterior */
  28.   public Component getComponentBefore(Container focusCycleRoot,
  29.                                       Component aComponent)
  30.   {
  31.     if (aComponent.equals(textoCondicion))
  32.       return textoPosicion;
  33.     if (aComponent.equals(textoPosicion))
  34.       return textoCantidad;
  35.     if (aComponent.equals(textoCantidad))
  36.       return textoCliente;
  37.     if (aComponent.equals(textoCliente))
  38.       return textoPrecio;
  39.     if (aComponent.equals(textoPrecio))
  40.       return textoInstrumento;
  41.     if (aComponent.equals(textoInstrumento))
  42.       return textoCondicion;
  43.  
  44.     return textoInstrumento;
  45.   }
  46.  
  47.   /**@param focusCycleRoot Raiz
  48.    * @return Componente por default */
  49.   public Component getDefaultComponent(Container focusCycleRoot)
  50.   {
  51.     return textoInstrumento;
  52.   }
  53.  
  54.   /**@param focusCycleRoot Raiz
  55.    * @return Ultimo componente */
  56.   public Component getLastComponent(Container focusCycleRoot)
  57.   {
  58.     return textoCondicion;
  59.   }
  60.  
  61.   /**@param focusCycleRoot Raiz
  62.    * @return Primer componente */
  63.   public Component getFirstComponent(Container focusCycleRoot)
  64.   {
  65.     return textoInstrumento;
  66.   }
  67.  
  68. } // Fin de la clase que maneja el focus
  69.  
  70.  
  71.  

Declaracion del los JTextFields:

Código: Text
  1.  
  2. JTextField textoInstrumento = new JTextField();  
  3. JTextField textoPrecio = new JTextField();  
  4. JTextField textoCliente = new JTextField();  
  5. JTextField textoCantidad = new JTextField();  
  6. JTextField textoPosicion = new JTextField();  
  7. JTextField textoCondicion = new JTextField();  
  8. JTextField textoCantidadHitTake = new JTextField();
  9.  
  10.  

Si miran el codigo en la politica de focos, veran que nunca aparece textoCantidadHitTake ya q quiero q este nunca tome el foco porque esta no visible casi todo el tiempo.

Bueno, si alguien sabe

Salu2!!!!!!

nicokiki

  • Miembro MUY activo
  • ***
  • Mensajes: 298
    • Ver Perfil
Re: Focustraversalpolicy Dudas
« Respuesta #1 en: Viernes 23 de Julio de 2004, 21:23 »
0
Por favor ayuda con estooooooooooooooooooooooo!!!!!!!!!!!!

JuanK no se te ocurre q puede estar pasando???

Salu2!!!!!

P.D.: no estoy exigiendo nada, solo pido ayuda con eso porque estoy terminando con el resto de las cosas q tengo q hacer y sigo con este problema