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

Win2000, JTextPane Tab jumps between windows

XMLWordPrintable

    • beta
    • x86
    • generic
    • Verified



      Name: jbT81659 Date: 12/14/2000

      OS: Win2000, SolSprc5.8
      JDK: JDK1.4.0-Beta44

      Tab functionality in JTextPane is broken. Tab jumps between
      different windows inside the frame instead of tabbing through JTextPane

      To reproduce bug:
      1- Compile and run the following code
      2- Go into the first JTextPane
      3- Press the TAB key once
      4- Note that TAB is not displayed in the first JTextPane
      5- Note that TAB is displayed in the second JTextPane
      5- Repeat STEP3
      6- Note that TAB keep jumping to the next JTextField

      ----Code------

      /* Copyright (c) Sun Microsystems 1999

      $Header: /home/sun/src/JDK1.2/jTextPane.java,v 1.17 2000/03/30 08:13:08 isam Exp $

      */

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

      public class jTextPane extends JApplet
      {
        public void init()
        {
          jTextPane1 jpane = new jTextPane1();
          getContentPane().add(jpane);
        }

        public static void main(String[] args)
        {
          JFrame frame = new JFrame("\u0645\u062b\u0627\u0644");
          frame.setContentPane(new jTextPane1());
          frame.pack();
          frame.setVisible(true);
              frame.addWindowListener( new WindowAdapter()
              {
                   public void windowClosing( WindowEvent e)
                   {
                       System.exit(0);
                   }
              });

        }
      }
      class jTextPane1 extends JPanel
      {
        public jTextPane1()
        {
          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("JTP1 implicit, left");
          pane = new JTextPane();
          pane.setFont(new Font("Lucida Sans Regular", Font.PLAIN, 9));
          l.setVerticalAlignment(SwingConstants.BOTTOM);
          l.setFont(new Font("Lucida Sans Regular", Font.PLAIN, 9));
          pane.setPreferredSize(new Dimension(320, 320));
          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(450,450));
          panel.add(p);

          p = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0));
          l = new JLabel("JTP2 explicit RTL, left");
          pane = new JTextPane();
          pane.setFont(new Font("Lucida Sans Regular", Font.PLAIN, 9));
          l.setVerticalAlignment(SwingConstants.BOTTOM);
          l.setFont(new Font("Lucida Sans Regular", Font.PLAIN, 9));
          pane.getDocument().putProperty(TextAttribute.RUN_DIRECTION,TextAttribute.RUN_DIRECTION_RTL);
          pane.setPreferredSize(new Dimension(320, 320));
          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(500,500));
          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, 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.setFont(new Font("Lucida Sans Regular", Font.PLAIN, 9));
          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");
          pane.setParagraphAttributes(rightStyle,true);
          p.setPreferredSize(new Dimension(500,500));
          p.add(l);
          p.add(pane);
          pane.setPreferredSize(new Dimension(320, 320));
          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, 9));
          pane = new JTextPane();
          pane.setFont(new Font("Lucida Sans Regular", Font.PLAIN, 9));
          pane.getDocument().putProperty(TextAttribute.RUN_DIRECTION,TextAttribute.RUN_DIRECTION_LTR);
          pane.setPreferredSize(new Dimension(320, 320));
          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(500,500));
          panel.add(p);
          
          panel.setPreferredSize(new Dimension(500,2000));

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

          add(scroll);
        }
      }



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

            shickeysunw Shannon Hickey (Inactive)
            jbenavrasunw Jonathan Benavraham (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: