Help For JrubyFX

Hi Community
i wana use this JAVAFX Code

in JrubyFX

class HelloWorldApp < JRubyFX::Application
def start(stage)
stage.initStyle(StageStyle::TRANSPARENT)
stage.title = “Hello World!”
stage.width = 600
stage.height = 400
text = Text.new(“Hi”)
text.setFont(Font.new(40))
box = VBox.new
box.getChildren.add(text);
scene = Scene.new(box,600,400)
scene.setFill(null)
stage.setScene(scene)
stage.show
end
end

HelloWorldApp.launch

but i have Problem in scene.setFill(null)
I dont know how should I use setFill in JrubyFx

Maybe scene.setFill(nil) or scene.fill = nil?

In Ruby, nil is the keyword for null references. It also adds attribute
accessor syntax so that you can interact with Java objects with
accessors as if they were POROs. E.g.
scene.fill=nil

Thanks,
Ariel

Sent from my mobile device. Please excuse any errors.

Actually, what is the status of JRubyFX? I haven’t seen new version of
it. Is it still in development?

Thanks!
Em 06/03/2015 07:46, “Ariel V.” [email protected]
escreveu:

I think what you want (transparent scene) you can get by looking at
samples/analog_clock.rb in the source repo. As others have said
setFill(nil) because null is not a valid value in Ruby.

-Tom

Thank you very much for the help my problem was resolved
But I have another problem
i wanna to make a window look like this
http://i.cubeupload.com/Zfogxo.png
but when i make this window with jrubyfx i cant transparent full
background
so for me is this
http://i.cubeupload.com/pK5nUr.png

My .rb code

require ‘jrubyfx’
import “javafx.stage.StageStyle”
import “javafx.application.Application”
import “javafx.scene.Scene”
import “javafx.scene.layout.VBox”
import “javafx.scene.text.Font”
import “javafx.scene.text.Text”
import “javafx.stage.Stage”

fxml_root File.dirname(FILE)

class HelloWorldApp < JRubyFX::Application

def start(stage)
      stage.fxml HelloWorldController
      stage.initStyle(StageStyle::TRANSPARENT)
      stage.title = "Hello World!"
      stage.width = 800
      stage.height = 600
      stage.show
end

end

class HelloWorldController
include JRubyFX::Controller
fxml “Hello.fxml”

def initialize
  super
  scene = @pane1.getScene()
  scene.setFill(nil)
end

def event_exit
    stage = @pane1.getScene().getWindow()
    stage.close()

end

end

HelloWorldApp.launch

And My .fxml code

<?xml version="1.0" encoding="UTF-8"?> <?import javafx.geometry.*?> <?import javafx.scene.image.*?> <?import java.lang.*?> <?import java.util.*?> <?import javafx.scene.control.*?> <?import javafx.scene.layout.*?> <?import javafx.scene.paint.*?> <?import javafx.scene.text.*?>






and my bg1.png
http://i.cubeupload.com/Jrw34A.gif

please help me and fix my code

Thank you for the answer

i put stage.scene.fill = nil in code
but Nothing changed Again
http://i.cubeupload.com/pK5nUr.png

style="-fx-background-image: url("Bg1.gif");

Can you add -fx-background-color: transparent to this? I checked your
Bg1.gif and has the background in the alpha channel.

Reference:

Thank you very much for your excellent guidance

i use this code for transparent
And dragged and move window

.rb file code

require ‘jrubyfx’
import “javafx.stage.StageStyle”
import “javafx.application.Application”
import “javafx.scene.Scene”
import “javafx.scene.layout.VBox”
import “javafx.scene.text.Font”
import “javafx.scene.text.Text”
import “javafx.stage.Stage”

fxml_root File.dirname(FILE)

class HelloWorldApp < JRubyFX::Application

def start(stage)
      stage.fxml HelloWorldController
      stage.initStyle(StageStyle::TRANSPARENT)
      stage.title = "Hello World!"
      stage.width = 800
      stage.height = 600
      stage.resizable = false
      stage.scene.fill = nil
      stage.show
end

end

class HelloWorldController
include JRubyFX::Controller
fxml “Hello.fxml”

def initialize
  super
  @scene = @pane1.getScene.getWindow
end

def event_exit
 @scene.close()
end


def bg_MouseUp
 @mflag = false
end

def bg_MouseMove(param)
 if (@mflag == true)
  @scene.x  = (@scene.x + param.x  - @x)
  @scene.y  = (@scene.y + param.y  - @y)
 end
end

def bg_MouseDown(param)
  @mflag = true
  @x = param.x
  @y = param.y
end

end

HelloWorldApp.launch

And fxml file

<?xml version="1.0" encoding="UTF-8"?> <?import javafx.geometry.*?> <?import javafx.scene.image.*?> <?import java.lang.*?> <?import java.util.*?> <?import javafx.scene.control.*?> <?import javafx.scene.layout.*?> <?import javafx.scene.paint.*?> <?import javafx.scene.text.*?>







plz test this code and dragged scene have some problem
No problem with slow movement mouse but when I’m increasing the speed
of the mouse my window Shaking

The scene.fill = nil is missing in your code. Try this:

class HelloWorldApp < JRubyFX::Application
  def start(stage)
    stage.fxml HelloWorldController
    stage.initStyle(StageStyle::TRANSPARENT)
    stage.scene.fill = nil
    stage.title = "Hello World!"
    stage.width = 800
    stage.height = 600
    stage.show
  end
end

References:

Sorry, I can’t test this, because I haven’t installed JRuby and JRubyFX.
:confused: