Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4143933

Can't change focus from Choice to JTextField

XMLWordPrintable

    • x86
    • windows_nt



      Name: eyC74480 Date: 05/29/98


      import java.awt.*;
      import java.awt.event.*;
      import com.sun.java.swing.*;

      public class joey extends Frame
      {
      Frame itsFrame;
      JTextField itsTF;

      public joey() {
      super("Joey");
      setLayout(new BorderLayout());
      itsFrame = this;
      setSize(400,400);

      System.out.println("JS: creating choice.");
      Choice aC = new Choice();
      add(aC,"North");
      aC.addItem("test1");
      aC.addItem("test2");
      aC.addItem("test3");
      aC.addItem("test4");
      aC.addItemListener(new ItemListener() {
      public void itemStateChanged(ItemEvent e) {
      System.out.println("JS: requesting focus.");
      itsTF.requestFocus();
      System.out.println("JS: focus owner is " + itsFrame.getFocusOwner());
      }
      });
      aC.addMouseListener(new MouseListener() {
      public void mouseClicked(MouseEvent e) {
      System.out.println("JS: in mouseClicked");
      System.out.println("JS: MC requesting focus.");
      itsTF.grabFocus();
      System.out.println("JS: MC focus owner is " + itsFrame.getFocusOwner());
      }
      public void mouseEntered(MouseEvent e) {
      System.out.println("JS: in mouseEntered");
      }
      public void mouseExited(MouseEvent e) {
      System.out.println("JS: in mouseExited");
      }
      public void mousePressed(MouseEvent e) {
      System.out.println("JS: in mousePressed");
      }
      public void mouseReleased(MouseEvent e) {
      System.out.println("JS: in mouseReleased");
      System.out.println("JS: MR requesting focus.");
      itsTF.grabFocus();
      System.out.println("JS: MR focus owner is " + itsFrame.getFocusOwner());
      }
      });

      itsTF = new JTextField(10);
      add(itsTF,"South");

      pack();
      show();
      }

      public static void main(String argv[]){
      joey aJ = new joey();
      }
      }
      (Review ID: 32662)
      ======================================================================

            son Oleg Sukhodolsky (Inactive)
            eyusunw Ellis Yu (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: