Forum: JRuby Help For JrubyFX

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
D5fedce345e999822fef5dd12e7cd20c?d=identicon&s=25 Parham Taheri (yanin)
on 2015-03-06 11:39
Hi Community
i wana use this JAVAFX Code
http://www.adam-bien.com/roller/abien/entry/comple...
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
18ddf0f491d9fc8825e1824e0903bef9?d=identicon&s=25 Benjamin Gudehus (Guest)
on 2015-03-06 11:43
(Received via mailing list)
Maybe scene.setFill(nil) or scene.fill = nil?
54147c1a1223b425d4f4f7947c9bba46?d=identicon&s=25 Ariel Valentin (Guest)
on 2015-03-06 11:46
(Received via mailing list)
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.
B97f192e676f1a67e0ef18f022671406?d=identicon&s=25 Rodrigo Botafogo (Guest)
on 2015-03-06 13:09
(Received via mailing list)
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 Valentin" <ariel@arielvalentin.com>
escreveu:
13313ac2ec7ba7c43b1b952db034ff3b?d=identicon&s=25 Thomas E Enebo (Guest)
on 2015-03-06 15:49
(Received via mailing list)
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
D5fedce345e999822fef5dd12e7cd20c?d=identicon&s=25 Parham Taheri (yanin)
on 2015-03-06 17:07
Attachment: Bg1.gif (30 KB)
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.*?>

<Pane fx:id="pane1" cacheShape="false" focusTraversable="true"
maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity"
minWidth="-Infinity" prefHeight="600.0" prefWidth="800.0"
style="-fx-background-image: url(&quot;Bg1.gif&quot;);
-fx-background-size: 800 600; -fx-background-position: center center;
-fx-background-repeat: stretch;" xmlns="http://javafx.com/javafx/8"
xmlns:fx="http://javafx.com/fxml/1">
   <children>
      <Button fx:id="btn1" layoutX="382.0" layoutY="41.0"
mnemonicParsing="false" onMouseClicked="#event_exit" text="Exit" />
      <TextField fx:id="text1" layoutX="325.0" layoutY="545.0" />
   </children>
</Pane>

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

please help me and fix my code
18ddf0f491d9fc8825e1824e0903bef9?d=identicon&s=25 Benjamin Gudehus (Guest)
on 2015-03-06 17:32
(Received via mailing list)
The scene.fill = nil is missing in your code. Try this:

~~~ruby
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:
http://www.adam-bien.com/roller/abien/entry/comple...
D5fedce345e999822fef5dd12e7cd20c?d=identicon&s=25 Parham Taheri (yanin)
on 2015-03-06 17:50
Thank you for the answer

i put stage.scene.fill = nil in code
but Nothing changed Again
http://i.cubeupload.com/pK5nUr.png
18ddf0f491d9fc8825e1824e0903bef9?d=identicon&s=25 Benjamin Gudehus (Guest)
on 2015-03-06 17:58
(Received via mailing list)
style="-fx-background-image: url(&quot;Bg1.gif&quot;);

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

Reference:
http://stackoverflow.com/questions/20164971/javafx...
D5fedce345e999822fef5dd12e7cd20c?d=identicon&s=25 Parham Taheri (yanin)
on 2015-03-06 23:13
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.*?>

<Pane fx:id="pane1" cacheShape="false" focusTraversable="true"
maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity"
minWidth="-Infinity" onMouseDragged="#bg_MouseMove"
onMousePressed="#bg_MouseDown" onMouseReleased="#bg_MouseUp"
prefHeight="600.0" prefWidth="800.0" style="-fx-background-color:
transparent; -fx-background-image: url(&quot;Bg1.gif&quot;);
-fx-background-size: 800 600; -fx-background-position: center center;
-fx-background-repeat: stretch;" xmlns="http://javafx.com/javafx/8"
xmlns:fx="http://javafx.com/fxml/1">
   <children>
      <Button fx:id="btn1" layoutX="382.0" layoutY="41.0"
mnemonicParsing="false" onMouseClicked="#event_exit" text="Exit" />
      <TextField fx:id="text1" layoutX="127.0" layoutY="544.0" />
      <TextField fx:id="text2" layoutX="516.0" layoutY="544.0" />
   </children>
</Pane>

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
18ddf0f491d9fc8825e1824e0903bef9?d=identicon&s=25 Benjamin Gudehus (Guest)
on 2015-03-06 23:27
(Received via mailing list)
Sorry, I can't test this, because I haven't installed JRuby and JRubyFX.
:/
This topic is locked and can not be replied to.