Programación General > Java

 Re: Focustraversalpolicy Dudas

(1/1)

nicokiki:
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 ---   public class PoliticaFocos extends FocusTraversalPolicy  {    /**@param focusCycleRoot Raiz     * @param aComponent Componente     * @return Siguiente componente */    public Component getComponentAfter(Container focusCycleRoot,                                       Component aComponent)    {      if (aComponent.equals(textoInstrumento))        return textoPrecio;      if (aComponent.equals(textoPrecio))        return textoCliente;      if (aComponent.equals(textoCliente))        return textoCantidad;      if (aComponent.equals(textoCantidad))        return textoPosicion;      if (aComponent.equals(textoPosicion))        return textoCondicion;      if (aComponent.equals(textoCondicion))        return textoInstrumento;      return textoInstrumento;    }     /**@param focusCycleRoot Raiz     * @param aComponent Componente     * @return Componente anterior */  public Component getComponentBefore(Container focusCycleRoot,                                      Component aComponent)  {    if (aComponent.equals(textoCondicion))      return textoPosicion;    if (aComponent.equals(textoPosicion))      return textoCantidad;    if (aComponent.equals(textoCantidad))      return textoCliente;    if (aComponent.equals(textoCliente))      return textoPrecio;    if (aComponent.equals(textoPrecio))      return textoInstrumento;    if (aComponent.equals(textoInstrumento))      return textoCondicion;     return textoInstrumento;  }   /**@param focusCycleRoot Raiz   * @return Componente por default */  public Component getDefaultComponent(Container focusCycleRoot)  {    return textoInstrumento;  }   /**@param focusCycleRoot Raiz   * @return Ultimo componente */  public Component getLastComponent(Container focusCycleRoot)  {    return textoCondicion;  }   /**@param focusCycleRoot Raiz   * @return Primer componente */  public Component getFirstComponent(Container focusCycleRoot)  {    return textoInstrumento;  } } // Fin de la clase que maneja el focus   
Declaracion del los JTextFields:


--- Código: Text --- JTextField textoInstrumento = new JTextField();  JTextField textoPrecio = new JTextField();  JTextField textoCliente = new JTextField();  JTextField textoCantidad = new JTextField();  JTextField textoPosicion = new JTextField();  JTextField textoCondicion = new JTextField();  JTextField textoCantidadHitTake = new JTextField();  
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:
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

Navegación

[0] Índice de Mensajes

Ir a la versión completa