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

JTable throws Locale related exceptions upon Copy and Paste between cells

    Details

    • Subcomponent:
    • Resolved In Build:
      rc1
    • CPU:
      generic
    • OS:
      generic
    • Verification:
      Verified

      Backports

        Description



        Name: jbT81659 Date: 03/29/2001

        OS: All tested platforms
        JDK: JDK1.3.1-rc1-b20

        Copying and Pasting from one table cell into another causes JVM to throw exceptions
        and JTable application to crash.
        The following is the exception thrown when I tried to copy and paste from one
        cell into another in the JTable testcase:
        ==================
        Exception occurred during event dispatching:
        java.awt.IllegalComponentStateException: This component must have a parent in order to determine its locale
            at java.awt.Component.getLocale(Component.java:1142)
            at javax.swing.text.GlyphView.getBreakSpotUseBreakIterator(GlyphView.java:679)
            at javax.swing.text.GlyphView.getBreakSpot(GlyphView.java:637)
            at javax.swing.text.GlyphView.getBreakWeight(GlyphView.java:577)
            at javax.swing.text.FlowView$FlowStrategy.layoutRow(FlowView.java:479)
            at javax.swing.text.TextLayoutStrategy.layoutRow(TextLayoutStrategy.java:110)
            at javax.swing.text.FlowView$FlowStrategy.layout(FlowView.java:423)
            at javax.swing.text.TextLayoutStrategy.layout(TextLayoutStrategy.java:93)
            at javax.swing.text.FlowView.layout(FlowView.java:182)
            at javax.swing.text.BoxView.setSize(BoxView.java:265)
            at javax.swing.text.FlowView$FlowStrategy.removeUpdate(FlowView.java:342)
            at javax.swing.text.TextLayoutStrategy.removeUpdate(TextLayoutStrategy.java:67)
            at javax.swing.text.FlowView.removeUpdate(FlowView.java:242)
            at javax.swing.plaf.basic.BasicTextFieldUI$I18nFieldView.removeUpdate(BasicTextFieldUI.java:378)
            at javax.swing.plaf.basic.BasicTextUI$RootView.removeUpdate(BasicTextUI.java:1352)
            at javax.swing.plaf.basic.BasicTextUI$UpdateHandler.removeUpdate(BasicTextUI.java:1589)
            at javax.swing.text.AbstractDocument.fireRemoveUpdate(AbstractDocument.java:228)
            at javax.swing.text.AbstractDocument.remove(AbstractDocument.java:477)
            at javax.swing.text.JTextComponent.setText(JTextComponent.java:1159)
            at javax.swing.DefaultCellEditor$1.setValue(DefaultCellEditor.java:63)
            at javax.swing.DefaultCellEditor.getTableCellEditorComponent(DefaultCellEditor.java:205)
            at javax.swing.JTable$GenericEditor.getTableCellEditorComponent(JTable.java:3333)
            at javax.swing.JTable.prepareEditor(JTable.java:3595)
            at javax.swing.JTable.editCellAt(JTable.java:2376)
            at javax.swing.plaf.basic.BasicTableUI$MouseInputHandler.mousePressed(BasicTableUI.java:464)
            at java.awt.AWTEventMulticaster.mousePressed(AWTEventMulticaster.java:221)
            at java.awt.Component.processMouseEvent(Component.java:3712)
            at java.awt.Component.processMouseEvent(Component.java:3712)
            at java.awt.Component.processEvent(Component.java:3544)
            at java.awt.Container.processEvent(Container.java:1164)
            at java.awt.Component.dispatchEventImpl(Component.java:2593)
            at java.awt.Container.dispatchEventImpl(Container.java:1213)
            at java.awt.Component.dispatchEvent(Component.java:2497)
            at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:2451)
            at java.awt.LightweightDispatcher.processMouseEvent(Container.java:2210)
            at java.awt.LightweightDispatcher.dispatchEvent(Container.java:2125)
            at java.awt.Container.dispatchEventImpl(Container.java:1200)
            at java.awt.Window.dispatchEventImpl(Window.java:914)
            at java.awt.Component.dispatchEvent(Component.java:2497)
            at java.awt.EventQueue.dispatchEvent(EventQueue.java:339)
            at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:131)
            at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:98)
            at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
            at java.awt.EventDispatchThread.run(EventDispatchThread.java:85)
        ==================

        To reproduce this behavior:

        1- Compile and run the (following) jTable.java test case under any platform
        2- Use the mouse to select some text fro a JTable cell
        3- Do "Ctrl+C" on the selected text to copy it
        4- Choose another cell
        5- Do "Ctrl+V" to paste the text
        6- Note that the above exception is thrown

        ==========Code================
        /* Copyright (c) Sun Microsystems 1998

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

        */

        import java.awt.*;
        import javax.swing.*;
        import java.awt.event.*;

        public class jTable extends JApplet
        {
        public void init()
           {
             SimpleTable st = new SimpleTable();
             getContentPane().add(st);
             }


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

        }
        }


        class SimpleTable extends JPanel
        {

        public SimpleTable()
        {

                        JTable jt = new JTable(new String[][]
             {
                        {"\u05d6\u05d5\u0020\u05e9\u05e0\u05d4\u0020\u05d9\u05e4\u05d4",
                        "\u0647\u0630\u0627\u0020\u064a\u0648\u0645\u0020\u0644\u0637\u064a\u0641\u0020\u05d6\u05d4\u0020\u05d9\u05d5\u05dd\u0020\u05e0\u05e2\u05d9\u05dd",
                        "\u062a\u0641\u0627\u062d\u0020\u0623\u062d\u0645\u0631\u0020\u0643\u0628\u064a\u0631\u0020\u0042\u0049\u0047\u0020\u0052\u0045\u0044\u0020\u0041\u0050\u0050\u004c\u0045\u0053",
                        "\u006c\u0069\u006d\u0065\u0020\u0069\u0073\u0020\u0067\u0072\u0065\u0065\u006e\u05d7\u05d5\u05de\u05d5\u05e1\u0020\u05d9\u05e7\u05e8"},
                        {"\u006c\u0069\u006d\u0065\u0020\u05d7\u05d5\u05de\u05d5\u05e1\u0020\u05d9\u05e7\u05e8\u0069\u0073\u0020\u0067\u0072\u0065\u0065\u006e",
                        "\u05d7\u05d5\u05de\u05d5\u05e1\u0020\u006c\u0069\u006d\u0065\u0020\u0069\u0073\u0020\u0067\u0072\u0065\u0065\u006e\u0020\u05d9\u05e7\u05e8","\u006c\u0069\u006d\u0065\u0020\u05d7\u05d5\u05de\u05d5\u05e1\u0020\u05d9\u05e7\u05e8\u0069\u0073\u0020\u0067\u0072\u0065\u0065\u006e"},
                        {"\u05d6\u05d5\u0020\u05e9\u05e0\u05d4\u0020\u05d9\u05e4\u05d4\u0020\u0054\u0048\u0045\u0020\u0059\u0045\u0041\u0052\u0020\u0031\u0039\u0035\u0038",
                       "\u05d7\u05d5\u05de\u05d5\u05e1\u0020\u006c\u0069\u006d\u0065\u0020\u0069\u0073\u0020\u0067\u0072\u0065\u0065\u006e\u0020\u05d9\u05e7\u05e8" ,"\u05d6\u05d5\u0020\u05e9\u05e0\u05d4\u0020\u05d9\u05e4\u05d4\u0020\u0054\u0048\u0045\u0020\u0059\u0045\u0041\u0052\u0020\u0031\u0039\u0035\u0038"}},
                       new String[] {"\u062a\u0641\u0627\u062d\u0020\u0623\u062d\u0645\u0631\u0020\u0643\u0628\u064a\u0631\u0020\u0042\u0049\u0047\u0020\u0052\u0045\u0044\u0020\u0041\u0050\u0050\u004c\u0045\u0053",
                       "\u0647\u0630\u0627\u0020\u064a\u0648\u0645\u0020\u0644\u0637\u064a\u0641\u0020\u05d6\u05d4\u0020\u05d9\u05d5\u05dd\u0020\u05e0\u05e2\u05d9\u05dd"});
            JScrollPane jsp = new JScrollPane(jt);
            jt.setFont(new Font("Lucida Sans Regular",Font.PLAIN,15));
            add(jsp, BorderLayout.CENTER);

           }
        }
        ==============================
        ======================================================================

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  svioletsunw Scott Violet (Inactive)
                  Reporter:
                  jbenavrasunw Jonathan Benavraham (Inactive)
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  0 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved:
                    Imported:
                    Indexed: