Exemple #1
0
 // This is a workaround for a java bug causing the caret to jump to 0
 // on focus gain since the value is recalculated. bug #4740914 (rejected)
 protected void processFocusEvent(FocusEvent e) {
   if (e.getID() == FocusEvent.FOCUS_GAINED) {
     Caret c = getCaret();
     int cd = getCaret().getDot();
     int cm = getCaret().getMark();
     super.processFocusEvent(e);
     // Assumes this won't go out of bounds (e.g. text didn't change).
     // This is normally a safe assumption, since it seems like the value can't change.
     c.setDot(cm);
     c.moveDot(cd);
   } else super.processFocusEvent(e);
 }
  /** ********************************************************************** */
  protected void processFocusEvent(FocusEvent fe) {
    switch (fe.getID()) {
      case FocusEvent.FOCUS_GAINED:
        setGrayed(false);
        break;

      case FocusEvent.FOCUS_LOST:
        setGrayed(true);
        break;

      default:
        return;
    }
  }
Exemple #3
0
  protected void processFocusEvent(FocusEvent e) {
    boolean lbContinuar = true;
    int id = e.getID();
    switch (id) {
      case FocusEvent.FOCUS_GAINED:
        super.setText(moTipo.getText());
        moBackColor = getBackground();
        setBackgroundP(moBackColorConFoco);
        setSelectionStart(0);
        setSelectionEnd(moTipo.getText().length());
        break;
      case FocusEvent.FOCUS_LOST:
        setBackgroundP(moBackColor);
        String lsTexto = super.getText();
        if (moTipo.isTipoCorrecto(lsTexto)) {
          moTipo.lostFocus(lsTexto);
          super.setText(moTipo.getTextFormateado());
        } else {
          lbContinuar = !moTipo.isTipoCorrectoObligatorio();
          if (lbContinuar) {
            moTipo.lostFocus(lsTexto);
            super.setText(moTipo.getTextFormateado());
          }

          utilesGUI.msgbox.JDialogo.showDialog(null, moTipo.getTextoError(lsTexto));
        }

        // anulamos la seleccion para que solo haya un campo con todo seleccionado
        if (lbContinuar) {
          setSelectionStart(0);
          setSelectionEnd(0);
          ponerColorSiCambio();
        }
        break;
      default:
    }
    super.processFocusEvent(e);
    // no se hace esto pq en windows se mete en un bucle infinito
    //        if(lbContinuar)
    //            super.processFocusEvent(e);
    //        else
    //            this.requestFocus();
  }
 void forwardFocusLost(FocusEvent e) {
   isFocused = false;
   FocusEvent fe =
       new FocusEvent(this, e.getID(), e.isTemporary(), e.getOppositeComponent(), e.getCause());
   super.processFocusEvent(fe);
 }
Exemple #5
0
  /*
   * (non-Javadoc)
   *
   * @see java.awt.Component#processFocusEvent(java.awt.event.FocusEvent)
   */
  @Override
  protected void processFocusEvent(FocusEvent e) {
    if (e.getID() == FocusEvent.FOCUS_GAINED) keyboardPanel.setTextField(this);

    super.processFocusEvent(e);
  }