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

Kestrel "P", ghost cursor in text components after executing Ctrl+Shift+O

XMLWordPrintable

    • beta
    • x86
    • generic, windows_98
    • Verified

        ======================================================================


        Name: jbT81659 Date: 11/23/99

        In JTextField, JTextArea and JTextPane, executing Ctrl+Shift+O causes the cursor image to
        stay in its original place. It will not disappear untill new cursor is put on top of it.

        To reproduce bug:
        Compile and run the following application.
        Use Ctrl+Shift+O to change component orientation for any text component.
        Note that cursor has stopped blinking
        Use mouse to click anywhere inside any text component
        Note that old cursor is still in its place
        Use mouse to click on old cursor
        Note that it is blincking again
        Use mouse to click any where else
        Note that old cursor disappeared
        Use Ctrl+shift+O on another text component
        Note that same problem occur


        -----Code--------
        /* Copyright (c) Sun Microsystems 1999

        $Header: /home/sun/src/JDK1.2/jTextComponent.java,v 1.4 1999/10/13 10:52:05 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(l.getFont().getName(), Font.ITALIC, 9));
            field = new JTextField(15);
            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(l.getFont().getName(), Font.ITALIC, 9));
            field = new JTextField(15);
            field.setHorizontalAlignment(JTextField.RIGHT);
            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(l.getFont().getName(), Font.ITALIC, 9));
            field = new JTextField(15);
            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(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(l.getFont().getName(), Font.ITALIC, 9));
            field = new JTextField(15);
            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("JTF5, explicit LTR, right");
            l.setVerticalAlignment(SwingConstants.BOTTOM);
            l.setFont(new Font(l.getFont().getName(), Font.ITALIC, 9));
            field = new JTextField(15);
            field.setHorizontalAlignment(JTextField.RIGHT);
            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(l.getFont().getName(), Font.ITALIC, 9));
            area = new JTextArea(3,15);
            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(l.getFont().getName(), Font.ITALIC, 9));
            area = new JTextArea(3,15);
            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(l.getFont().getName(), Font.ITALIC, 9));
            area = new JTextArea(3,15);
            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\u0643\u0628\u064a\u0631 ÇáÎØ ÇáÓÇÎä áÇÊÍÇÏ ãäÊÌí ÇáÈÑÇãÌ ÇáãÚáæãÇÊíÉ¡ íÞæÏ Åáì ãÕÇÏÑÉ ÃÌåÒÉ ãáÞøãÉ ÈÈÑÇãÌ ãäÓæÎÉ¡ æÒÇÑÉ ÇáÅÚáÇã ÊÄßÏ ÏÚãåÇ áÍãÇíÉ ÍÞæÞ ÇáãáßíÉ ÏÈí :21 äæÝãÈÑ 1999 ÇÞÊÍãÊ ÓáØÇÊ ÏÈí ãÍáÇó áÈíÚ ÃÌåÒÉ ÇáßãÈíæÊÑ Ýí ÃÍÏ ãÑÇßÒ ÇáÊÓæøÞ ÇáãÒÏÍãÉ Ýí ÏÈí¡ ÍíË ÖÈØÊ äÓÎ ÛíÑ ÞÇäæäíÉ áäÙÇã ÇáÊÔÛíá ÇáæíäÏæÒ 98 æãÌãæÚÉ ÇáÈÑÇãÌ ÇáãßÊÈíøÉ ÃæÝíÓ 97 . æÊãÊ ÇáÚãáíÉ ÅËÑ ãßÇáãÉ åÇÊÝíÉ ÈÅÊÍÇÏ ãäÊÌí ÇáÈÑÇãÌ ÇáãÚáæãÇÊíÉ ÞÇã ÈåÇ ÔÎÕ áã íÛÑÝ Úä ÇÓãå. æÚáÞ ÃÔæß ÔÇÑãÇ¡ ãÏíÑ ÇÊÍÇÏ ãäÊÌí ÈÑÇãÌ ÇáãÚáæãÇÊí øÉ Ýí ÇáÔÑÞ ÇáÃæÓØ ÞÇÆáÇó: ÈÚÏ ÊÌÇæÈåÇ ÇáÓÑíÚ ÝÞÏ ÃÙåÑÊ æÒÇÑÉ ÇáÅÚáÇã Ýí ÏãÚáæãÇÊ Ýí ÇáÚÇáã ÇáÚÑÈí Èí ÃäåÇ ÓÊÊÎÐ ÇáÅÌÑÇÁÇÊ Çá ÓÑíÚÉ æÇáÕÇÑãÉ Ýí ÍÞ ãÍíØ ÃÝÖá¡ ããÇ íÚÒÒ ãßÇäÉ ÇáÈáÏ ßãÑßÒ ÑÆíÓí áÊÞäíÉ Çá ßá ãä íÍÇæá ÇáÊÚÏí Úáì ÞÇäæä ÏæáÉ ÇáÅãÇÍÉ¡ ÊÄßøÏ Ãä ÇáÅãÇÑÇÊ ÇáÚÑÈíÉ ÇáãÊÍÏÉ ãÓ ÊãÑÉ ÈÇáÊÞÏøã áÊåíÆÉÑÇÊ áÍãÇíÉ ÇáãáßíÉ ÇáÝßÑíÉ¡ æÇáÐí ÃÞÑø á ÍãÇíÉ ãáÈí. æÞÇá ÃíÖÇð: Åä ÇáÎØæÉ ÇáÊí ÇÊÎÐÊåÇ ÇáæÒÇÑÉ ÇáÈÇÑßíÉ ÇáÔÑßÇÊ ÇáãÚá!
        !
        æãÇÊíøÉ æÇáãáßíÉ ÇáÝßÑíÉ áãäÊÚáåÇ ÃÞá ÈáÏ ÇÓÊÎÏÇãÇð ááÈÑÇãÌ ÇáãäÓæÎÉ Ýí ÇáÚ Çáã ÇáÚÑÌí ÇáÈÑÇãÌ ÇáãÚáæãÇÊíÉ Ýí ÇáÔÑÞ ÇáÃæÓØ æÇáÚÇáã Ýí ÇáÅãÇÑÇÊ ÊÑÇÌÚ ÈØÑíÞÉ ãÝÇÌÆÉ Åáì ÃÞá ãä 50%¡ ãÇ Ìãä Íæáå. ßãÇ ÃÖÇÝ: Åä Úáì ãæÒøÚí ÇáÈÑÇãÌ ÇáãÚáæáÈÑÇãÌ ÇáãäÓæÎÉ Ýí ÇáãäØÞÉ. Åä ãÚÏøá ÇáÈÑÇãÌ ÇáãäÓæÎ ÉãÇÊíøÉ Ýí ÇáÅãÇÑÇÊ ÇáÚÑÈíÉ ÇáãÊÍÏÉ ÇÍÊÑÇã åÐÇ ÇáÞÇäæ äÇãÌ ÇáãäÓæÎÉ¡ ÃßÓÈåÇ ãßÇäÉ ÚÇáãíÉ Ýí ÇáÍÑÈ ÖÏ Ç æãÞÇæãÉ ÑÛÈÉ ÈíÚ ÇáÈÑÇãÌ ÇáãäÓæÎÉ æÐáß áÍãÇÇÝ ÔÇÑãÇ: Åä ãæÞÝ ÍßæãÉ ÇáÅãÇÑÇÊ ÇáÚÑÈíÉ ÇáãÊÍÏÉ ãä ÇáÈ ÑíÉ ÃÚãÇáåã æÔÑßÇÊåã ãä ÇáÅÞÝÇá¡ åÐÇ ÈÇáÅÖÇÝÉ Åáì ÚÞæÈÉ ÇáÓÑÞÉ æÇáÊÚæíÖÇÊ ÇáãÍÊãá ÝÑÖåÇ Úáíåã. ßãÇ ÃÖ");
            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();
            l.setVerticalAlignment(SwingConstants.BOTTOM);
            l.setFont(new Font(l.getFont().getName(), Font.ITALIC, 9));
            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(l.getFont().getName(), Font.ITALIC, 9));
            pane.getDocument().putProperty(TextAttribute.RUN_DIRECTION,TextAttribute.RUN_DIRECTION_RTL);
            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(l.getFont().getName(), Font.ITALIC, 9));
            pane = new JTextPane();
            pane.getDocument().putProperty(TextAttribute.RUN_DIRECTION,TextAttribute.RUN_DIRECTION_RTL);
            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(l.getFont().getName(), Font.ITALIC, 9));
            pane = new JTextPane();
            pane.getDocument().putProperty(TextAttribute.RUN_DIRECTION,TextAttribute.RUN_DIRECTION_LTR);
            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(l.getFont().getName(), Font.ITALIC, 9));
            pane = new JTextPane();
            pane.setParagraphAttributes(rightStyle,true);
            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:
        ======================================================================

        Name: krT82822 Date: 02/27/2000


        (see also 4293752, 4293760)

        there is a problem with JTextArea that is :
        when i use setComponentOrientation(RIGTH_TO_LEFT) to let the cursor be from
        right i.e right side of a box for arabic support it does not work.

        this is a sample code explain the problem.
        import java.awt.*;
        import java.awt.event.*;
        import javax.swing.*;

        public class TextAreaTest extends javax.swing.JFrame {
        JTextArea JTextArea1 ;
            
        public TextAreaTest() {
        try{
        JTextArea1 = new JTextArea();
        }catch(Exception e){
        }
        setTitle("JFC Application");

        setDefaultCloseOperation(javax.swing.JFrame.DO_NOTHING_ON_CLOSE);
        getContentPane().setLayout(null);
        setSize(488,309);
        setVisible(false);
        JButton1.setText("jbutton");
        getContentPane().add(JButton1);
        JButton1.setBounds(144,216,156,40);

        getContentPane().add(JTextArea1);
        JTextArea1.setBounds(120,84,192,108);
        //this is for arabic supporte to let the curor appeare from
        rigth
        // but it does not work
                JTextArea1.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
        //{{REGISTER_LISTENERS
        SymWindow aSymWindow = new SymWindow();
        this.addWindowListener(aSymWindow);
        SymAction lSymAction = new SymAction();
        //}}
        }

            /**
             * Creates a new instance of JFrame1 with the given title.
             * @param sTitle the title for the new frame.
             * @see #JFrame1()
             */
        public TextAreaTest(String sTitle)
        {
        this();
        setTitle(sTitle);
        }

        /**
        * The entry point for this application.
        * Sets the Look and Feel to the System Look and Feel.
        * Creates a new JFrame1 and makes it visible.
        */
        static public void main(String args[]){
        try {
        //Create a new instance of our application's frame, and
        make it visible.
        (new TextAreaTest()).setVisible(true);
        }
        catch (Throwable t) {
        t.printStackTrace();
        //Ensure the application exits with an error condition.
        System.exit(1);
        }
        }

        //{{DECLARE_CONTROLS
        javax.swing.JButton JButton1 = new javax.swing.JButton();
        //}}

        //{{DECLARE_MENUS
        //}}

        void exitApplication()
        {
        try {
        // Beep
        Toolkit.getDefaultToolkit().beep();
        // Show a confirmation dialog
        int reply = JOptionPane.showConfirmDialog(this,
        "Do you really want
        to exit?",
        "JFC Application -
        Exit" ,

        JOptionPane.YES_NO_OPTION,

        JOptionPane.QUESTION_MESSAGE);
        // If the confirmation was affirmative, handle exiting.
        if (reply == JOptionPane.YES_OPTION)
        {
        this.setVisible(false); // hide the Frame
        this.dispose(); // free the system resources
        System.exit(0); // close the application
        }
        } catch (Exception e) {
        }
        }

        class SymWindow extends java.awt.event.WindowAdapter
        {
        public void windowClosing(java.awt.event.WindowEvent event)
        {
        Object object = event.getSource();
        if (object == TextAreaTest.this)
        TextAreaTest_windowClosing(event);
        }
        }

        void TextAreaTest_windowClosing(java.awt.event.WindowEvent event)
        {
        // to do: code goes here.

        TextAreaTest_windowClosing_Interaction1(event);
        }

        void TextAreaTest_windowClosing_Interaction1(java.awt.event.WindowEvent
        event) {
        try {
        this.exitApplication();
        } catch (Exception e) {
        }
        }

        class SymAction implements java.awt.event.ActionListener
        {
        public void actionPerformed(java.awt.event.ActionEvent event)
        {
        Object object = event.getSource();

        }
        }
        }
        (Review ID: 101784)

              peytoia Yuka Kamiya (Inactive)
              jbenavrasunw Jonathan Benavraham (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: