Created
July 5, 2013 11:07
-
-
Save komax/5933828 to your computer and use it in GitHub Desktop.
Grid Pane from http://docs.oracle.com/javafx/2/get_started/form.htm#BABHABBF in jrubyfx
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
require 'java' | |
require 'jrubyfx' | |
JavaFX = Java::javafx | |
class FormApp < JRubyFX::Application | |
def start(stage) | |
stage.set_title("JavaFX Welcome") | |
grid = JavaFX::scene.layout.GridPane.new | |
grid.alignment = JavaFX.geometry.Pos::CENTER | |
grid.hgap = 10 | |
grid.vgap = 10 | |
grid.padding = JavaFX.geometry.Insets.new(25, 25, 25, 25) | |
scenetitle = JavaFX.scene.text.Text.new("Welcome") | |
scenetitle.font = JavaFX.scene.text.Font.font("Tahoma", | |
JavaFX.scene.text.FontWeight::NORMAL, 20) | |
grid.add(scenetitle, 0, 0, 2, 1) | |
user_name = JavaFX.scene.control.Label.new("User Name:") | |
grid.add(user_name, 0, 1) | |
user_text_field = JavaFX.scene.control.TextField.new | |
grid.add(user_text_field, 1, 1) | |
pw = JavaFX::scene::control::Label.new("Password:") | |
grid.add(pw, 0, 2) | |
pw_box = JavaFX::scene::control::PasswordField.new | |
grid.add(pw_box, 1, 2) | |
# for debugging: shows spaces between added Controls | |
grid.grid_lines_visible = true | |
button = JavaFX::scene::control::Button.new("Sign in") | |
hbox_button = JavaFX::scene::layout::HBox.new(10) | |
hbox_button.alignment = JavaFX::geometry::Pos::BOTTOM_RIGHT | |
hbox_button.children.add(button) | |
grid.add(hbox_button, 1, 4) | |
actiontarget = JavaFX::scene::text::Text.new | |
grid.add(actiontarget, 1, 6) | |
button.set_on_action do | |
#puts "foo" | |
actiontarget.fill = JavaFX::scene::paint::Color::FIREBRICK | |
actiongarget.text = "Sign in button pressed" | |
end | |
scene = JavaFX.scene.Scene.new(grid, 300, 275) | |
stage.scene = scene | |
stage.show | |
end | |
end | |
FormApp.launch |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment