Oi Lista
 
O seguinte c�digo esta me deixando de cabelo em p�... estou tentando fazer uma checagem apos a digita��o de alguma informa��o atrav�s do m�todo jTextField2_focusLost(FocusEvent e) que esta no c�digo abaixo, e o FOCUS na janela Frame1 fica doid�o. O cursor chega a aparecer em 2 campos TextFields ao mesmo tempo, depois que � passado pelo focus lost...... Depois o java desativa este m�todo de tratamento automaticamente.... Oq fazer?  Acho que � um pau no Java no Windows. J� tentei de tudo.. E acho impossivel que alguem n�o tenha utilizado este tipo de tratamento de campo....  O trecho mais importante est� em vermelho mais ao final.... Este programinha apresenta um Frame com 3 campos TextField, sendo o tratamento programado para o segundo campo.  
Estou usando w2000, jBuilder 4 e muita f�....
 
Um Abra�o
Leandro
 
 
 
 
 
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------c�digo doid�o....
 
package untitled1;
 
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import com.borland.jbcl.layout.*;
 
public class Frame1 extends JFrame {
  JPanel contentPane;
  XYLayout xYLayout1 = new XYLayout();
  JTextField jTextField1 = new JTextField();
  JLabel jLabel1 = new JLabel();
  JTextField jTextField2 = new JTextField();
  JLabel teste = new JLabel();
  JTextField jTextField3 = new JTextField();
  JLabel teste1 = new JLabel();
 
  /**Construct the frame*/
  public Frame1() {
    enableEvents(AWTEvent.WINDOW_EVENT_MASK);
    try {
      jbInit();
    }
    catch(Exception e) {
      e.printStackTrace();
    }
  }
  /**Component initialization*/
  private void jbInit() throws Exception  {
    jTextField1.setText("jTextField1");
    //setIconImage(Toolkit.getDefaultToolkit().createImage(Frame1.class.getResource("[Your Icon]")));
    contentPane = (JPanel) this.getContentPane();
    contentPane.setLayout(xYLayout1);
    this.setSize(new Dimension(400, 300));
    this.setTitle("Frame Title");
    jLabel1.setToolTipText("");
    jLabel1.setText("Digite Algo");
    jTextField2.setText("jTextField2");
    jTextField2.addFocusListener(new java.awt.event.FocusAdapter() {
      public void focusLost(FocusEvent e) {
        if ( ! e.isTemporary() )
          jTextField2_focusLost(e);
      }
    });

    teste.setText("jLabel2");
    jTextField3.setText("jTextField2");
    teste1.setText("jLabel2");
    contentPane.add(jTextField1, new XYConstraints(86, 89, 225, -1));
    contentPane.add(jLabel1, new XYConstraints(86, 69, -1, -1));
    contentPane.add(jTextField2, new XYConstraints(88, 141, 223, -1));
    contentPane.add(teste, new XYConstraints(90, 123, -1, -1));
    contentPane.add(jTextField3, new XYConstraints(88, 190, 223, -1));
    contentPane.add(teste1, new XYConstraints(90, 172, -1, -1));
  }
  /**Overridden so we can exit when window is closed*/
  protected void processWindowEvent(WindowEvent e) {
    super.processWindowEvent(e);
    if (e.getID() == WindowEvent.WINDOW_CLOSING) {
      System.exit(0);
    }
  }
 
  void jTextField2_focusLost(FocusEvent e) {
 
//------------>Trecho mais importante que deixa tudo meio doido.....
 
        JOptionPane opc = new JOptionPane();
        String retorno=opc.showInputDialog("digite algo!!!" );
        new JOptionPane().showMessageDialog( this, "Voce digitou:"+retorno );
 
//------------> este trecho inativa o FOCUS do frame Anterior... Porque??  Estes comandos foram tirados de manuais da pr�pria SUN.
 
  }
}

Responder a