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

Add Event Handler for System Clipboard

XMLWordPrintable

    • generic
    • generic

      A DESCRIPTION OF THE PROBLEM :
      DESCRIPTION:
      Currently, there is limited support for changing content of the system clipboard (the only method is Clipboard#setContent()), which is totally fine.
      However, there is no acceptable way to observe when a change to the clipboard happens (the only way somewhat possible is through using the com.sun.javafx package with the ClipboardHelper as far as I have seen, which should most likely not be used by programmers outside of direct JavaFX development).
      This is a nuisance as various components modify the clipboard without the programmer knowing about that.
      There are two equally bad workarounds when all clipboard contents are important:
      a) You poll the system clipboard after certain intervals, risking to ignore certain changes.
      b) You avoid using all prebuilt UI components that can modify the clipboard. This means implementing your own subtypes for every component used that can modify the clip board. That is not maintainable for projects of any size.

      EXPECTED SOLUTION:
      Some kind of event listener should be called when Clipboard#setContent() gets called.
      In its easiest form this is just a Consumer<Map<DataFormat,?>>.
      A more complex (or in my opinion unnecessary) approach would be to define a whole event for it.
      If it is intended to be even more complicated, certain data formats could define their own listener that get called for all corresponding changes of the given DataFormat.
      Of course, there should be getters and setters implemented for the listeners.

      This feature should not change any public API in a backwards-incompatible way and thus integrate easily with the currently existing clipboard.


            arapte Ambarish Rapte
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: