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

JTextField on a JDialog positions cursor at the end of the text.

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 1.2.2, 1.3.0
    • client-libs
    • generic, x86
    • generic, windows_nt



      Name: skT45625 Date: 04/07/2000


      java version "1.2.2"
      Classic VM (build JDK-1.2.2-001, native threads, symcjit)

      The behavior of JTextField and where it positions the cursor is different
      depending on whether the JTextField is on a JFrame or a JDialog.


      Reproduction:

      import javax.swing.*;
      import java.awt.*;
      import java.awt.event.*;

      public class Test extends JFrame
      {
         public Test()
         {
            Container contentPane = getContentPane();
            contentPane.setLayout(new GridLayout(4, 1));
            contentPane.add(new JLabel("Press tab - JTextField positions cursor at
      start of text"));
            JButton button = new JButton("Dialog");
            contentPane.add(button);
            addTextFields(contentPane);
            button.addActionListener(new ActionListener()
            {
               public void actionPerformed(ActionEvent e)
               {
                  TestDialog td = new TestDialog();
                  td.show();
               }
            });

         }

         class TestDialog extends JDialog
         {
            public TestDialog()
            {
               setTitle("JDialog");
               Container contentPane = getContentPane();
               contentPane.setLayout(new GridLayout(4, 1));
               contentPane.add(new JLabel("Press tab - JTextField positions cursor at
      end of text"));
               contentPane.add(new JButton("dummy"));
               addTextFields(contentPane);
               pack();
            }
         }

         private void addTextFields(Container contentPane)
         {
            TextField text = new TextField("TextField");
            contentPane.add(text);
            JTextField jtext = new JTextField("JTextField");
            contentPane.add(jtext);
         }

         public static void main(String[] args)
         {
            JFrame f = new Test();
            f.setTitle("JFrame");
            f.addWindowListener(new WindowAdapter()
            {
               public void windowClosing(WindowEvent e)
               {
                  System.exit(0);
               }
            });

            f.pack();
            f.setVisible(true);
         }
      }

      ###@###.### 2000-04-07
      Reproduced in 1.3.0rc3 & 1.4.0beta
      (Review ID: 103403)
      ======================================================================

            apikalev Andrey Pikalev
            skondamasunw Suresh Kondamareddy (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: