Class TableCopyPasteAdapter

java.lang.Object
smile.swing.table.TableCopyPasteAdapter
All Implemented Interfaces:
ActionListener, EventListener

public class TableCopyPasteAdapter extends Object implements ActionListener
TableCopyPasteAdapter enables Copy-Paste Clipboard functionality on JTables. The clipboard data format used by the adapter is compatible with the clipboard format used by Excel. This provides for clipboard inter-operability between enabled JTables and Excel.
  • Method Details

    • apply

      public static TableCopyPasteAdapter apply(JTable table)
      Creates and attaches a copy-paste adapter for a table.
      Parameters:
      table - the table.
      Returns:
      an adapter.
    • actionPerformed

      public void actionPerformed(ActionEvent e)
      This method is activated on the Keystrokes we are listening to in this implementation. Here it listens for Copy and Paste ActionCommands. Selections comprising non-adjacent cells result in invalid selection and then copy action cannot be performed. Paste is done by aligning the upper left corner of the selection with the 1st element in the current selection of the JTable.
      Specified by:
      actionPerformed in interface ActionListener