J-_-L
index | github | twitter | irbtools | pws | rubykraut | ruby on ubuntu | zucker | euler | fresh
09.01.12
1 comment

Access the system clipboard with JRuby

This is my first jruby code (written for the clipboard gem) and I was quite surprised that you only need one-liners ;)

 1
2
3
4
5
6
7
def copy(text)
  Java::JavaAwt::Toolkit.default_toolkit.system_clipboard.set_contents(Java::JavaAwtDatatransfer::StringSelection.new(text), nil)
end

def paste
  Java::JavaAwt::Toolkit.default_toolkit.system_clipboard.get_data(Java::JavaAwtDatatransfer::DataFlavor.stringFlavor)
end
Creative Commons License

Comments

04.04.12

juwi

Looks good. Been toying with it, too a little. JRuby is Java done right ;-)

24.05.13
2|

you?

name
www
7plus3
gist #