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

JTextPane text display is broken and exceptions are thrown

    Details

      Description



      Name: jbT81659 Date: 10/29/2000

      Merlin-B38, So9laris Sparc, JTextPane throws exceptions when executed:

      -------------
      Exception occurred during event dispatching:
      java.lang.IllegalArgumentException: range 19 to 39 is invalid for paragraph of length 20
              at java.text.Bidi.createLineBidi(Bidi.java:259)
              at java.awt.font.TextMeasurer.makeTextLineOnRange(TextMeasurer.java:439)
              at java.awt.font.TextMeasurer.getLayout(TextMeasurer.java:566)
              at java.awt.font.LineBreakMeasurer.nextLayout(LineBreakMeasurer.java:422)
              at javax.swing.text.TextLayoutStrategy.createView(TextLayoutStrategy.java:199)
              at javax.swing.text.FlowView$FlowStrategy.layoutRow(FlowView.java:438)
              at javax.swing.text.TextLayoutStrategy.layoutRow(TextLayoutStrategy.java:111)
              at javax.swing.text.FlowView$FlowStrategy.layout(FlowView.java:394)
              at javax.swing.text.TextLayoutStrategy.layout(TextLayoutStrategy.java:94)
              at javax.swing.text.FlowView.setSize(FlowView.java:183)
              at javax.swing.text.AsyncBoxView$ChildState.updateChild(AsyncBoxView.java:1241)
              at javax.swing.text.AsyncBoxView$ChildState.run(AsyncBoxView.java:1182)
              at javax.swing.text.AsyncBoxView$ChildLocator.getChildAllocation(AsyncBoxView.java:978)
              at javax.swing.text.AsyncBoxView$ChildLocator.getChildAllocation(AsyncBoxView.java:945)
              at javax.swing.text.AsyncBoxView.modelToView(AsyncBoxView.java:745)
              at javax.swing.text.ZoneView$Zone.modelToView(ZoneView.java:560)
              at javax.swing.text.CompositeView.modelToView(CompositeView.java:242)
              at javax.swing.text.BoxView.modelToView(BoxView.java:445)
              at javax.swing.plaf.basic.BasicTextUI$RootView.modelToView(BasicTextUI.java:1296)
              at javax.swing.plaf.basic.BasicTextUI.modelToView(BasicTextUI.java:838)
              at javax.swing.text.DefaultCaret.paint(DefaultCaret.java:424)
              at javax.swing.plaf.basic.BasicTextUI.paintSafely(BasicTextUI.java:547)
              at javax.swing.plaf.basic.BasicTextUI.paint(BasicTextUI.java:677)
              at javax.swing.plaf.basic.BasicTextUI.update(BasicTextUI.java:656)
              at javax.swing.JComponent.paintComponent(JComponent.java:430)
              at javax.swing.JComponent.paint(JComponent.java:689)
              at javax.swing.JComponent.paintChildren(JComponent.java:536)
              at javax.swing.JComponent.paint(JComponent.java:698)
              at javax.swing.JComponent.paintChildren(JComponent.java:536)
              at javax.swing.JComponent.paint(JComponent.java:698)
              at javax.swing.JComponent.paintChildren(JComponent.java:536)
              at javax.swing.JComponent.paintWithOffscreenBuffer(JComponent.java:4257)
              at javax.swing.JComponent.paintDoubleBuffered(JComponent.java:4203)
              at javax.swing.JComponent._paintImmediately(JComponent.java:4155)
              at javax.swing.JComponent.paintImmediately(JComponent.java:3987)
              at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:399)
              at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(SystemEventQueueUtilities.java:120)
              at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:154)
              at java.awt.EventQueue.dispatchEvent(EventQueue.java:421)
              at java.awt.EventDispatchThread.pumpOneEvent(EventDispatchThread.java:136)
              at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:122)
              at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:118)
              at java.awt.EventDispatchThread.run(EventDispatchThread.java:98)
      ---------------------------
      Here is the code for jTextPane.java
      =======

      /* 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:
      ======================================================================

        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: