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

Ghost cursor appears at location of text change from RTL to LTR in all text comp

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P4
    • Resolution: Cannot Reproduce
    • Affects Version/s: 1.3.0
    • Fix Version/s: None
    • Component/s: client-libs

      Description



      Name: jbT81659 Date: 03/27/2000

      compile and run attached code (jTextComponent.java).

      All text fields, areas and panes come initialized with bidi text.
      Start with JTextField1 and scroll the cursor through text.
      Note that once you move from RTL text to LTR text a ghost cursor appears and stays.
      Move to other text components in application and perform this test.
      Note that all text components share this problem.

      ----Code----

      /* Copyright (c) Sun Microsystems 1999

      $Header: /home/sun/src/JDK1.2/jTextComponent.java,v 1.3 1999/09/26 10:17:58 isam Exp $

      */

      import java.awt.*;
      import java.awt.font.*;
      import javax.swing.*;
      import javax.swing.border.*;
      import javax.swing.text.*;

      public class jTextComponent extends JApplet
      {
        public void init()
        {
          jTextComponent1 jTextComponent2 = new jTextComponent1();
          getContentPane().add(jTextComponent2);
        }

        public static void main(String[] args)
        {
          JFrame frame = new JFrame("\u0645\u062b\u0627\u0644");
          frame.setContentPane(new jTextComponent1());
          frame.pack();
          frame.setVisible(true);
        }
      }
      class jTextComponent1 extends JPanel
      {
        public jTextComponent1()
        {
          JLabel l;
          JPanel p;
          JTextField field;
          JTextArea area;
          JTextPane pane;
          JPanel panel = new JPanel(new FlowLayout(FlowLayout.LEFT));

          p = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0));
          l = new JLabel("JTF1, implicit, left");
          l.setVerticalAlignment(SwingConstants.BOTTOM);
          l.setFont(new Font("Lucida Sans Regular",Font.PLAIN,18));
          field = new JTextField(15);
          field.setFont(new Font("Lucida Sans Regular",Font.PLAIN,18));
          field.setText("\u062a\u0641\u0627\u062d\u0020\u0623\u062d\u0645\u0631\u0020\u05d9\u05d5\u05dd\u0020\u05e0\u05e2\u05d9\u05dd");
          p.add(l);
          p.add(field);
          p.setPreferredSize(new Dimension(175,60));
          panel.add(p);

          p = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0));
          l = new JLabel("JTF2, explicit RTL, right");
          l.setVerticalAlignment(SwingConstants.BOTTOM);
          l.setFont(new Font("Lucida Sans Regular",Font.PLAIN,18));
          field = new JTextField(15);
          field.setHorizontalAlignment(JTextField.RIGHT);
          field.setFont(new Font("Lucida Sans Regular",Font.PLAIN,18));
          field.getDocument().putProperty(TextAttribute.RUN_DIRECTION,TextAttribute.RUN_DIRECTION_RTL);
          field.setText("\u0053\u0074\u0061\u0072\u0074\u0020\u062a\u0641\u0627\u062d\u0020\u0623\u062d\u0645\u0631\u0020\u05d9\u05d5\u05dd\u0020\u05e0\u05e2\u05d9\u05dd");
          p.add(l);
          p.add(field);
          p.setPreferredSize(new Dimension(200,60));
          panel.add(p);

          p = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0));
          l = new JLabel("JTF3, explicit RTL, left");
          l.setVerticalAlignment(SwingConstants.BOTTOM);
          l.setFont(new Font("Lucida Sans Regular",Font.PLAIN,18));
          field = new JTextField(15);
          field.getDocument().putProperty(TextAttribute.RUN_DIRECTION,TextAttribute.RUN_DIRECTION_RTL);
          field.setFont(new Font("Lucida Sans Regular",Font.PLAIN,18));
          field.setText("\u0053\u0074\u0061\u0072\u0074\u0020\u062a\u0641\u0627\u062d\u0020\u0623\u062d\u0645\u0631\u0020\u05d9\u05d5\u05dd\u0020\u05e0\u05e2\u05d9\u05dd");
          p.add(l);
          p.add(field);
          p.setPreferredSize(new Dimension(175,60));
          panel.add(p);

          p = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0));
          l = new JLabel("JTF4, explicit LTR, left");
          l.setVerticalAlignment(SwingConstants.BOTTOM);
          l.setFont(new Font("Lucida Sans Regular",Font.PLAIN,18));
          field = new JTextField(15);
          field.getDocument().putProperty(TextAttribute.RUN_DIRECTION,TextAttribute.RUN_DIRECTION_LTR);
          field.setFont(new Font("Lucida Sans Regular",Font.PLAIN,18));
          field.setText("\u062a\u0641\u0627\u062d\u0020\u0623\u062d\u0645\u0631\u0020\u05d9\u05d5\u05dd\u0020\u05e0\u05e2\u05d9\u05dd");
          p.add(l);
          p.add(field);
          p.setPreferredSize(new Dimension(175,60));
          panel.add(p);

          p = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0));
          l = new JLabel("JTF5, explicit LTR, right");
          l.setVerticalAlignment(SwingConstants.BOTTOM);
          l.setFont(new Font("Lucida Sans Regular",Font.PLAIN,18));
          field = new JTextField(15);
          field.setHorizontalAlignment(JTextField.RIGHT);
          field.setFont(new Font("Lucida Sans Regular",Font.PLAIN,18));
          field.getDocument().putProperty(TextAttribute.RUN_DIRECTION,TextAttribute.RUN_DIRECTION_LTR);
          field.setText("\u062a\u0641\u0627\u062d\u0020\u0623\u062d\u0645\u0631\u0020\u05d9\u05d5\u05dd\u0020\u05e0\u05e2\u05d9\u05dd");
          p.add(l);
          p.add(field);
          p.setPreferredSize(new Dimension(175,60));
          panel.add(p);

          p = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0));
          l = new JLabel("JTA1, implicit, left");
          l.setVerticalAlignment(SwingConstants.BOTTOM);
          l.setFont(new Font("Lucida Sans Regular",Font.PLAIN,18));
          area = new JTextArea(3,15);
          area.setFont(new Font("Lucida Sans Regular",Font.PLAIN,18));
          area.setText("\u062a\u0641\u0627\u062d\u0020\u0623\u062d\u0645\u0631\u0020\u05d9\u05d5\u05dd\u0020\u05e0\u05e2\u05d9\u05dd");
          area.setLineWrap(true);
          p.add(l);
          p.add(area);
          p.setPreferredSize(new Dimension(175,110));
          panel.add(p);

          p = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0));
          l = new JLabel("JTA2, explicit RTL, left");
          l.setVerticalAlignment(SwingConstants.BOTTOM);
          l.setFont(new Font("Lucida Sans Regular",Font.PLAIN,18));
          area = new JTextArea(3,15);
          area.setFont(new Font("Lucida Sans Regular",Font.PLAIN,18));
          area.setLineWrap(true);
          area.getDocument().putProperty(TextAttribute.RUN_DIRECTION,TextAttribute.RUN_DIRECTION_RTL);
          area.setText("\u0053\u0074\u0061\u0072\u0074\u0020\u062a\u0641\u0627\u062d\u0020\u0623\u062d\u0645\u0631\u0020\u05d9\u05d5\u05dd\u0020\u05e0\u05e2\u05d9\u05dd");
          p.add(l);
          p.add(area);
          p.setPreferredSize(new Dimension(175,110));
          panel.add(p);

          p = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0));
          l = new JLabel("JTA3, explicit LTR, left");
          l.setVerticalAlignment(SwingConstants.BOTTOM);
          l.setFont(new Font("Lucida Sans Regular",Font.PLAIN,18));
          area = new JTextArea(3,15);
          area.setFont(new Font("Lucida Sans Regular",Font.PLAIN,18));
          area.setLineWrap(true);
          area.getDocument().putProperty(TextAttribute.RUN_DIRECTION,TextAttribute.RUN_DIRECTION_LTR);
          area.setText("\u062a\u0641\u0627\u062d\u0020\u0623\u062d\u0645\u0631\u0020\u05d9\u05d5\u05dd\u0020\u05e0\u05e2\u05d9\u05dd");
          p.add(l);
          p.add(area);
          p.setPreferredSize(new Dimension(175,110));
          panel.add(p);

          p = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0));
          l = new JLabel("JTP1 implicit, left");
          pane = new JTextPane();
          pane.setFont(new Font("Lucida Sans Regular",Font.PLAIN,18));
          l.setVerticalAlignment(SwingConstants.BOTTOM);
          l.setFont(new Font("Lucida Sans Regular",Font.PLAIN,18));
          pane.setPreferredSize(new Dimension(180,250));
          pane.setText("\u062a\u0641\u0627\u062d\u0020\u0623\u062d\u0645\u0631\u0020\u05d9\u05d5\u05dd\u0020\u05e0\u05e2\u05d9\u05dd");
          p.add(l);
          p.add(pane);
          p.setPreferredSize(new Dimension(175,160));
          panel.add(p);

          p = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0));
          l = new JLabel("JTP2 explicit RTL, left");
          pane = new JTextPane();
          l.setVerticalAlignment(SwingConstants.BOTTOM);
          l.setFont(new Font("Lucida Sans Regular",Font.PLAIN,18));
          pane.getDocument().putProperty(TextAttribute.RUN_DIRECTION,TextAttribute.RUN_DIRECTION_RTL);
          pane.setFont(new Font("Lucida Sans Regular",Font.PLAIN,18));
          pane.setPreferredSize(new Dimension(180,250));
          pane.setText("\u0053\u0074\u0061\u0072\u0074\u0020\u062a\u0641\u0627\u062d\u0020\u0623\u062d\u0645\u0631\u0020\u05d9\u05d5\u05dd\u0020\u05e0\u05e2\u05d9\u05dd");
          p.add(l);
          p.add(pane);
          p.setPreferredSize(new Dimension(175,160));
          panel.add(p);

          p = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0));
          l = new JLabel("JTP3 explicit RTL, right");
          l.setVerticalAlignment(SwingConstants.BOTTOM);
          l.setFont(new Font("Lucida Sans Regular",Font.PLAIN,18));
          pane = new JTextPane();
          pane.getDocument().putProperty(TextAttribute.RUN_DIRECTION,TextAttribute.RUN_DIRECTION_RTL);
          pane.setFont(new Font("Lucida Sans Regular",Font.PLAIN,18));
          pane.setFont(new Font("Lucida Sans Regular",Font.PLAIN,18));
          MutableAttributeSet rightStyle;
          rightStyle = new SimpleAttributeSet();
          StyleConstants.setAlignment(rightStyle,StyleConstants.ALIGN_RIGHT);
          StyledDocument doc = pane.getStyledDocument();
          SimpleAttributeSet a = new SimpleAttributeSet();
          pane.setParagraphAttributes(rightStyle,true);
          pane.setPreferredSize(new Dimension(180,250));
          pane.setText("\u0053\u0074\u0061\u0072\u0074\u0020\u062a\u0641\u0627\u062d\u0020\u0623\u062d\u0645\u0631\u0020\u05d9\u05d5\u05dd\u0020\u05e0\u05e2\u05d9\u05dd");
          p.add(l);
          p.add(pane);
          p.setPreferredSize(new Dimension(175,160));
          panel.add(p);

          p = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0));
          l = new JLabel("JTP4 explicit LTR, left");
          l.setVerticalAlignment(SwingConstants.BOTTOM);
          l.setFont(new Font("Lucida Sans Regular",Font.PLAIN,18));
          pane = new JTextPane();
          pane.getDocument().putProperty(TextAttribute.RUN_DIRECTION,TextAttribute.RUN_DIRECTION_LTR);
          pane.setFont(new Font("Lucida Sans Regular",Font.PLAIN,18));
          pane.setPreferredSize(new Dimension(180,250));
          pane.setText("\u062a\u0641\u0627\u062d\u0020\u0623\u062d\u0645\u0631\u0020\u05d9\u05d5\u05dd\u0020\u05e0\u05e2\u05d9\u05dd");
          p.add(l);
          p.add(pane);
          p.setPreferredSize(new Dimension(175,160));
          panel.add(p);
          
          p = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0));
          l = new JLabel("JTP5 explicit LTR, right");
          l.setVerticalAlignment(SwingConstants.BOTTOM);
          l.setFont(new Font("Lucida Sans Regular",Font.PLAIN,18));
          pane = new JTextPane();
          pane.setParagraphAttributes(rightStyle,true);
          pane.setFont(new Font("Lucida Sans Regular",Font.PLAIN,18));
          pane.setPreferredSize(new Dimension(180,250));
          pane.setText("\u062a\u0641\u0627\u062d\u0020\u0623\u062d\u0645\u0631\u0020\u05d9\u05d5\u05dd\u0020\u05e0\u05e2\u05d9\u05dd");
          p.add(l);
          p.add(pane);
          p.setPreferredSize(new Dimension(175,160));
          panel.add(p);

          panel.setPreferredSize(new Dimension(200,1900));

          JScrollPane scroll = new JScrollPane(panel);
          scroll.setPreferredSize(new Dimension(210,450));

          add(scroll);
        }
      }


      WorkAround:
      ======================================================================

        Attachments

          Activity

            People

            Assignee:
            bcbeck Brian Beck (Inactive)
            Reporter:
            jbenavrasunw Jonathan Benavraham (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: