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

Motif LAF, Cursor does not change direction when leaving RTL into LTR and vice v

    Details

      Description

      Name: jbT81659 Date: 03/28/2000

      Motif LAF, Cursor does not change direction when leaving RTL into LTR and vice versa
      in the following swing text components: JTextField, JTextArea, JTextPane and JPasswordField.

      To examine this problem:
      Compile the following code.
      Execute the code using:
      java -Dswing.defaultlaf=com.sun.java.swing.plaf.motif.MotifLookAndFeel jTextComponent

      In all textfields, textareas and textpanes, insert LTR chars. and scroll the cursor.
      Note that cursor does not change direction as it leaves RTL to LTR and vice versa.

      ---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,12));
          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,12));
          field = new JTextField(15);
          field.setHorizontalAlignment(JTextField.RIGHT);
          field.setFont(new Font("Lucida Sans Regular",Font.PLAIN,12));
          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,12));
          field = new JTextField(15);
          field.getDocument().putProperty(TextAttribute.RUN_DIRECTION,TextAttribute.RUN_DIRECTION_RTL);
          field.setFont(new Font("Lucida Sans Regular",Font.PLAIN,12));
          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,12));
          field = new JTextField(15);
          field.getDocument().putProperty(TextAttribute.RUN_DIRECTION,TextAttribute.RUN_DIRECTION_LTR);
          field.setFont(new Font("Lucida Sans Regular",Font.PLAIN,12));
          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,12));
          field = new JTextField(15);
          field.setHorizontalAlignment(JTextField.RIGHT);
          field.setFont(new Font("Lucida Sans Regular",Font.PLAIN,12));
          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,12));
          area = new JTextArea(3,15);
          area.setFont(new Font("Lucida Sans Regular",Font.PLAIN,12));
          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,12));
          area = new JTextArea(3,15);
          area.setFont(new Font("Lucida Sans Regular",Font.PLAIN,12));
          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,12));
          area = new JTextArea(3,15);
          area.setFont(new Font("Lucida Sans Regular",Font.PLAIN,12));
          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,12));
          l.setVerticalAlignment(SwingConstants.BOTTOM);
          l.setFont(new Font("Lucida Sans Regular",Font.PLAIN,12));
          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,12));
          pane.getDocument().putProperty(TextAttribute.RUN_DIRECTION,TextAttribute.RUN_DIRECTION_RTL);
          pane.setFont(new Font("Lucida Sans Regular",Font.PLAIN,12));
          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,12));
          pane = new JTextPane();
          pane.getDocument().putProperty(TextAttribute.RUN_DIRECTION,TextAttribute.RUN_DIRECTION_RTL);
          pane.setFont(new Font("Lucida Sans Regular",Font.PLAIN,12));
              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,12));
          pane = new JTextPane();
          pane.getDocument().putProperty(TextAttribute.RUN_DIRECTION,TextAttribute.RUN_DIRECTION_LTR);
          pane.setFont(new Font("Lucida Sans Regular",Font.PLAIN,12));
          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,12));
          pane = new JTextPane();
          pane.setParagraphAttributes(rightStyle,true);
          pane.setFont(new Font("Lucida Sans Regular",Font.PLAIN,12));
          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:
              shickeysunw Shannon Hickey (Inactive)
              Reporter:
              jbenavrasunw Jonathan Benavraham (Inactive)
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Imported:
                Indexed: