[jruby-user] Re: Help For JrubyFX

Parham Taheri <[email protected]> Fri, 06 Mar 2015 23:13:40 +0100
Newsgroups gmane.comp.lang.jruby.user
Message-ID <[email protected]>
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

-- 
Posted via http://www.ruby-forum.com/.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email