Sunday, January 29, 2017

Jython 11. Text

This Example, Text, will produce the same output as Java Example 11. We never use something like a new keyword, here as well as in or the previous examples, since Python or Jython variables aren't declared. We can always check if the type is what we intend by using the type keyword.


# ex11.py
# Text

from javafx.application import Application
from javafx.scene import Scene
from javafx.scene import Group
from javafx.scene.paint import Color
from javafx.scene.text import Font
from javafx.scene.text import Text

class Ex11(Application):
    def start(self, stage):
        stage.setTitle("Example 11. Text")
        root = Group()
        
        text = Text(10,60,"Hello\nText\nWorld!")
        text.setFont(Font("Georgia",50))
        print type(text)
        
        root.getChildren().add(text)
        
        scene = Scene(root, 400, 200, Color.HONEYDEW)
        stage.setScene(scene)
        stage.show()

if __name__ == '__main__':
    Application.launch(Ex11().class, [])

We should get that the type is:
<type 'javafx.scene.text.Text'>

1 comment:

  1. Software developers in Ukraine have a strong skill set, they are tech savvy, up to date with recent innovations and have an independent thinking. Moreover, Ukraine offers intermediate prices of $25-$49/hour for its software developers in comparison to the engineers from other eastern European countries. Learn more about Ukrainian programmers.

    ReplyDelete