Created
January 31, 2013 00:50
-
-
Save retorquere/4678888 to your computer and use it in GitHub Desktop.
Tree drag and drop
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env jruby | |
require 'jrubyfx' | |
java_import 'javafx.scene.control.TreeCell' | |
class MyTreeCell < TreeCell | |
def updateItem(item, empty) | |
super(item, empty) | |
text = item unless item | |
end | |
end | |
class Hello < JRubyFX::Application | |
def start(stage) | |
with(stage, title: "Hello Devoxx", x: 105, y: 140) do | |
layout_scene(500, 250, :black) do | |
hbox(padding: insets(60)) do | |
root = tree_item("Root") | |
1.upto(5) {|i| | |
root.children.add(tree_item("File #{i}")) | |
} | |
tree_view(root) do | |
set_cell_factory do | |
MyTreeCell.new.tap do |tree_cell| | |
tree_cell.set_on_drag_detected do |mouse_event| | |
# ... | |
end | |
end | |
end | |
end | |
end | |
end | |
show | |
end | |
end | |
end | |
Hello.launch |
enebo
commented
Jan 31, 2013
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment