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

Cursor loops infinitely in JTextField with Arabic currency symbols and numbers

    Details

      Description

      Name: jbT81659 Date: 01/29/2004

      Locale: ar_SA, ar_EG, iw_IL, en_US
      Regression: NO
      Build: B32

      For JTextfields that contain numerals and Arabic currency symbols, the cursor loops infinitely between the currency symbol characters and never moves through the digits in the JTextField. This behavior is seen in JTextFields with default Text alignment.

      To reproduce bug:

      1. Compile and run the following test case (currencyTest.java)
      2. Position the cursor at the Home position in the first JTextField (iw_IL)
      3. press the right arrow key on keyboard to move cursor through Text
      4. Note that cursor move from Home to End as expected
      5. Move to the next JTextField (ar_SA)
      6. Position the cursor at the Home position in the JTextField
      6. Hold and press the left arrow key on keyboard
      7. Note that the cursor moves infinitely between the currency symbol characters
      8. Move to the next JTxtField (ar_EG)
      9. Position the cursor at the Home position in the JTextField
      10. Hold and press the left arrow key on keyboard
      11. Note that the cursor moves infinitely between the currency symbol characters


      --------------cyrrenctTest,java-----------------------------
      /* Copyright (c) Sun Microsystems 2004
      $Header: $
      */

      import java.applet.*;
      import javax.swing.*;
      import java.awt.*;
      import javax.swing.event.*;
      import javax.swing.text.*;
      import javax.swing.border.*;
      import java.awt.event.*;
      import java.text.*;
      import java.util.*;

      public class currencyTest extends JApplet
      {
          public void init()
          {
              currTest test = new currTest();
              getContentPane().add(test);
          }
      public static void main(String[] argv)
      {
                  JFrame frame = new JFrame("\u0645\u062b\u0627\u0644");
           frame.setContentPane(new currTest());
           frame.setSize(800, 800);
             frame.setVisible(true);
                  frame.addWindowListener( new WindowAdapter()
                  {
                     public void windowClosing( WindowEvent e)
                     {
                      System.exit(0);
                     }
                  });
              }
      }

      class currTest extends JPanel
      {
          public currTest()
          {
              JTextField f;
              JTextPane describtion;
              JLabel l, locale;
              JPanel p, panel, last;
              p = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0));
              panel = new JPanel(new FlowLayout(FlowLayout.LEFT));
              Locale[] locales = { new Locale("iw","IL"),
                                   new Locale("ar","SA"),
                                   new Locale("ar","EG"),
                                   new Locale("en","US") };

              Double currency;
              NumberFormat currencyFormatter;
              String currencyOut;


              p = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0));
              currency = new Double(9876543.21);
              currencyFormatter = NumberFormat.getCurrencyInstance(locales[0]);
              currencyOut = currencyFormatter.format(currency);
              locale = new JLabel(locales[0].toString()+" ");
              locale.setForeground(Color.blue);
              l = new JLabel(currencyOut);
              f = new JTextField(currencyOut);
              f.setPreferredSize(new Dimension(150,30));
              l.setPreferredSize(new Dimension(150,30));
              l.setBorder(new EtchedBorder());
              locale.setPreferredSize(new Dimension(150,30));
              p.setPreferredSize(new Dimension(480,60));
              p.add(locale,BorderLayout.WEST);
              p.add(l, BorderLayout.CENTER);
              p.add(f, BorderLayout.EAST);
              panel.add(p);

              p = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0));
              currency = new Double(9876543.21);
              currencyFormatter = NumberFormat.getCurrencyInstance(locales[1]);
              currencyOut = currencyFormatter.format(currency);
              locale = new JLabel(locales[1].toString()+" ");
              locale.setForeground(Color.blue);
              l = new JLabel(currencyOut);
              f = new JTextField(currencyOut);
              f.setPreferredSize(new Dimension(150,30));
              l.setPreferredSize(new Dimension(150,30));
              l.setBorder(new EtchedBorder());
              locale.setPreferredSize(new Dimension(150,30));
              p.setPreferredSize(new Dimension(480,60));
              p.add(locale,BorderLayout.WEST);
              p.add(l, BorderLayout.CENTER);
              p.add(f, BorderLayout.EAST);
              panel.add(p);

              p = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0));
              currency = new Double(9876543.21);
              currencyFormatter = NumberFormat.getCurrencyInstance(locales[2]);
              currencyOut = currencyFormatter.format(currency);
              locale = new JLabel(locales[2].toString()+" ");
              locale.setForeground(Color.blue);
              l = new JLabel(currencyOut );
              f = new JTextField(currencyOut);
              f.setPreferredSize(new Dimension(150,30));
              l.setPreferredSize(new Dimension(150,30));
              l.setBorder(new EtchedBorder());
              locale.setPreferredSize(new Dimension(150,30));
              p.setPreferredSize(new Dimension(480,60));
              p.add(locale,BorderLayout.WEST);
              p.add(l, BorderLayout.CENTER);
              p.add(f, BorderLayout.EAST);
              panel.add(p);

              p = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0));
              currency = new Double(9876543.21);
              currencyFormatter = NumberFormat.getCurrencyInstance(locales[3]);
              currencyOut = currencyFormatter.format(currency);
              locale = new JLabel(locales[3].toString()+" ");
              locale.setForeground(Color.blue);
              l = new JLabel(currencyOut);
              f = new JTextField(currencyOut);
              f.setPreferredSize(new Dimension(150,30));
              l.setPreferredSize(new Dimension(150,30));
              l.setBorder(new EtchedBorder());
              locale.setPreferredSize(new Dimension(150,30));
              p.setPreferredSize(new Dimension(480,60));
              p.add(locale,BorderLayout.WEST);
              p.add(l, BorderLayout.CENTER);
              p.add(f, BorderLayout.EAST);
              panel.add(p);

              p = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0));
              p.setPreferredSize(new Dimension(600,100));
              describtion = new JTextPane();
              describtion.setContentType("text/html");
              describtion.setEditable(false);
              describtion.setText("<html><body><br>1. Verify that the locale is displayed as the first item to the left <br>2. Verify that the currency symbol is displayed to the left of the number in JLabel <br> 3. Verify that the currency symbol is displayed to the left of the number in JTextField <br>4. If the currency symbol is displayed to the right of the number, the test case fails</body></html>");

              describtion.setBackground(Color.lightGray);
              describtion.setPreferredSize(new Dimension(600,100));
              p.add(describtion,BorderLayout.CENTER);
              panel.add(p);
              panel.setPreferredSize(new Dimension(800,1000));
              add(panel);


          }
      }

      ------------------------------------------------------------
      ======================================================================

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                peterz Peter Zhelezniakov (Inactive)
                Reporter:
                jbenavrasunw Jonathan Benavraham (Inactive)
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: