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

JTable,JTree,JList: Pasted data is not always the same as the copied data.

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 1.4.1
    • 1.4.0
    • client-libs
    • hopper
    • x86
    • windows_2000
    • Verified

      Copying from JTable, JList or JTree and then changing the data in the component that was copied from, can cause pastes to use the new edited data. To see this in action:

      Run SwingSet2
      Go to the JTable demo.
      Turn on both column selection and row selection.
      Click on a cell (not double click which will start editing).
      Hit CTRL-C
      Edit the cell.
      Double click on another cell to start editing. Hit CTRL-V.
      Note that the new edited data is pasted and not what was originally copied.

      This can potentially happen with JTree, JTable and JList.


      Original Description:
      ---------------------------------------------------------------------
      Name: gm110360 Date: 10/23/2001


      java version "1.4.0-beta2"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-beta2-b77)
      Java HotSpot(TM) Client VM (build 1.4.0-beta2-b77, mixed mode)


      Select a non-editable JTable cell, copy with ctrl-C, change the value of cell,
      paste somewhere else in same app. The new value gets pasted instead of the
      original one. It seems like a reference to the cell is going into the
      clipboard rather than the value of the cell. This is wrong. This bug may be
      related to bug 4436431.




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


      class CopyBug {

      public static void main(String[] args) throws Exception {
      final JFrame frame = new JFrame();
      final Container contentPane = frame.getContentPane();
      contentPane.setLayout(new FlowLayout());

      final DefaultTableModel model =
      new DefaultTableModel(
      new String[][]{{"copy this"}}
      , new String[][]{{"whatever"}}
      ) {
      public boolean isCellEditable(int row,int
      column) {
      return false;
      }
      }
      ;
      final JTable table = new JTable(model);
      contentPane.add(table);

      JButton btn = new JButton("<-- change");
      btn.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e) {
      model.setValueAt("changed",0,0);
      }
      } );
      contentPane.add(btn);

      contentPane.add( new JLabel("now paste -->") );

      contentPane.add( new JTextField(20) );

      frame.pack();
      frame.setVisible(true);
      }
      }

      Release Regression From : 1.3.1_01
      The above release value was the last known release where this
      bug was knwon to work. Since then there has been a regression.
      (Review ID: 134293)
      ======================================================================

            shickeysunw Shannon Hickey (Inactive)
            gmanwanisunw Girish Manwani (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: