bug-classpath
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug classpath/22966] New: swing: JTextArea.setText("") causes StringInd


From: timo dot lindfors at iki dot fi
Subject: [Bug classpath/22966] New: swing: JTextArea.setText("") causes StringIndexOutOfBoundsException later
Date: 22 Aug 2005 16:24:44 -0000

Steps to reproduce:
1. Compile and run the attached testcase.

Expected results:
1. A window shows up. It has an empty 10x40 textara.

Actual results:
1. No window is shown and program throws the following exception:
java.lang.StringIndexOutOfBoundsException
   at java.lang.String.<init> (String.java:512)
   at java.lang.String.<init> (String.java:237)
   at gnu.java.awt.peer.gtk.GdkFontMetrics.charsWidth (GdkFontMetrics.java:97)
   at javax.swing.text.PlainView.getPreferredSpan (PlainView.java:228)
   at javax.swing.plaf.basic.BasicTextUI$RootView.getPreferredSpan 
(BasicTextUI.java:136)
   at javax.swing.plaf.basic.BasicTextUI.getPreferredSize (BasicTextUI.java:464)
   at javax.swing.JComponent.getPreferredSize (JComponent.java:1032)
   at javax.swing.JRootPane$RootLayout.preferredLayoutSize (JRootPane.java:278)
   at java.awt.Container.preferredSize (Container.java:626)
   at java.awt.Container.getPreferredSize (Container.java:613)
   at javax.swing.JComponent.getPreferredSize (JComponent.java:1036)
   at java.awt.BorderLayout.calcCompSize (BorderLayout.java:655)
   at java.awt.BorderLayout.calcSize (BorderLayout.java:700)
   at java.awt.BorderLayout.preferredLayoutSize (BorderLayout.java:454)
   at java.awt.Container.preferredSize (Container.java:626)
   at java.awt.Container.getPreferredSize (Container.java:613)
   at javax.swing.JFrame.getPreferredSize (JFrame.java:91)
   at java.awt.Window.pack (Window.java:267)
   at textarea.<init> (textarea.java:11)
   at textarea.main (textarea.java:4)

Testcase:
import javax.swing.*;
public class textarea extends JFrame {
        public static void main(String[] a) {
                (new textarea()).show();
        }
        public textarea() {  
                JTextArea textarea = new JTextArea(10, 40);
                textarea.setText("text0
");
                textarea.setText("");
                this.setContentPane(textarea);
                this.pack();
        }
}

Note that this is very similar to bug 13230.
------- Additional Comments From from-classpath at savannah dot gnu dot org  
2005-06-03 13:41 -------
I get a different exception:



Exception during event dispatch:

java.lang.ArrayIndexOutOfBoundsException: -6

   at javax.swing.text.Utilities.drawTabbedText (Utilities.java:100)

   at javax.swing.text.PlainView.drawUnselectedText (PlainView.java:151)

   at javax.swing.text.PlainView.drawLine (PlainView.java:127)

   at javax.swing.text.PlainView.paint (PlainView.java:174)

   at javax.swing.plaf.basic.BasicTextUI$RootView.paint (BasicTextUI.java:145)

   at javax.swing.plaf.basic.BasicTextUI.paintSafely (BasicTextUI.java:501)

   at javax.swing.plaf.basic.BasicTextUI.paint (BasicTextUI.java:486)

   at javax.swing.plaf.ComponentUI.update (ComponentUI.java:187)

   at javax.swing.JComponent.paintComponent (JComponent.java:1500)





but still, not as expected... :-(
------- Additional Comments From from-classpath at savannah dot gnu dot org  
2005-06-03 14:32 -------
Please test again, I have checked in a possible fix for this.



/Roman
------- Additional Comments From from-classpath at savannah dot gnu dot org  
2005-06-04 23:48 -------
Seems to work now.
------- Additional Comments From timo dot lindfors at iki dot fi  2005-08-22 
16:24 -------
This bug should be reopened as the testcase seems to throw
StringIndexOutOfBoundsException with current classpath cvs head
2005-08-22T14:57:08+0000. As the line numbers might have changed, here's the
exception again:

java.lang.StringIndexOutOfBoundsException
   at java.lang.String.<init> (String.java:516)
   at java.lang.String.<init> (String.java:241)
   at gnu.java.awt.peer.gtk.GdkFontMetrics.charsWidth (GdkFontMetrics.java:97)
   at javax.swing.text.PlainView.getPreferredSpan (PlainView.java:228)
   at javax.swing.plaf.basic.BasicTextUI$RootView.getPreferredSpan
(BasicTextUI.java:190)
   at javax.swing.JTextArea.getPreferredSize (JTextArea.java:545)
   at javax.swing.JRootPane$RootLayout.preferredLayoutSize (JRootPane.java:278)
   at java.awt.Container.preferredSize (Container.java:661)
   at java.awt.Container.getPreferredSize (Container.java:642)
   at javax.swing.JComponent.getPreferredSize (JComponent.java:1047)
   at java.awt.BorderLayout.calcCompSize (BorderLayout.java:586)
   at java.awt.BorderLayout.calcSize (BorderLayout.java:632)
   at java.awt.BorderLayout.preferredLayoutSize (BorderLayout.java:399)
   at java.awt.Container.preferredSize (Container.java:661)
   at java.awt.Container.getPreferredSize (Container.java:642)
   at javax.swing.JFrame.getPreferredSize (JFrame.java:136)
   at java.awt.Window.pack (Window.java:270)
   at textarea.<init> (textarea.java:11)
   at textarea.main (textarea.java:4)


-- 
           Summary: swing: JTextArea.setText("") causes
                    StringIndexOutOfBoundsException later
           Product: classpath
           Version: unspecified
            Status: RESOLVED
          Severity: normal
          Priority: P3
         Component: classpath
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: from-classpath at savannah dot gnu dot org
                CC: bug-classpath at gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=22966




reply via email to

[Prev in Thread] Current Thread [Next in Thread]