Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package fxone;
- import javafx.application.Application;
- import javafx.scene.Group;
- import javafx.scene.Scene;
- import javafx.scene.paint.Color;
- import javafx.scene.shape.Line;
- import javafx.stage.Stage;
- /**
- *
- * knb
- bem10jfx.blogspot.com
- numagrandeviagem.blogspot.com
- */
- public class lines extends Application{
- @Override
- public void start(Stage stglines) throws Exception {
- Group go=new Group();
- Scene scene=new Scene(go,300,300,Color.ALICEBLUE);
- stglines.setScene(scene);
- Line lnEX[]=new Line[6];
- for (int i = 1; i < 6; i++) {
- lnEX[i]=new Line();
- go.getChildren().add(lnEX[i]);
- }
- /* binds tem as características de receber
- dados inteiros e trabalhá-los de maneira
- que otimize os retornos de valores....
- tambem funcionam de forma que se algum WindowsEvent for iniciado no programa
- como Maximizar , restaurar, ou mover as propriedades de dimenções ,
- os binds irão sincronizar de acordo com as dimenções e a localidades do obgeto
- */
- /*bind 1 inicia a linha do ponto 0 (zero) ate a extremidade da scene*/
- lnEX[1].setLayoutX(10);
- lnEX[1].setLayoutY(20);
- lnEX[1].setStartX(0);
- lnEX[1].setStartY(20);
- lnEX[1].endXProperty().bind(scene.widthProperty());
- lnEX[1].setEndY(20);
- /*bind 2 cor vermelho inicia a linha o LayoutY no
- ponto 25 e o x no Width 30 utilizando o bind*/
- lnEX[2].layoutXProperty().bind(scene.widthProperty().divide(10));
- lnEX[2].layoutYProperty().bind(scene.heightProperty().divide(35));
- lnEX[2].setStartY(20);
- lnEX[2].setStartX(1);
- lnEX[2].setEndY(20);
- lnEX[2].setEndX(220);
- lnEX[2].setStroke(Color.RED);
- /*bind3 retornando bind
- lnEX[3].setStroke(Color.GREENYELLOW);
- lnEX[3].setStartY(scene.getHeight()-scene.getHeight());
- lnEX[3].setStartX(scene.getWidth()-scene.getWidth());
- lnEX[3].setEndY(scene.getHeight());
- lnEX[3].setEndX(scene.getWidth());
- */
- lnEX[3].setStroke(Color.GREENYELLOW);
- lnEX[3].startYProperty().bind(
- scene.heightProperty().subtract(
- scene.heightProperty().add(20)
- )
- );
- lnEX[3].startXProperty().bind(
- scene.widthProperty().divide(
- scene.widthProperty().add(10)
- )
- );
- lnEX[3].endYProperty().bind(scene.heightProperty().subtract(10));
- lnEX[3].endXProperty().bind(scene.widthProperty().subtract(10));
- /*bind4 retornando bind
- */
- lnEX[4].setStroke(Color.BLUEVIOLET);
- lnEX[4].startYProperty().bind(
- scene.heightProperty().subtract(scene.heightProperty().add(10))
- );
- lnEX[4].startXProperty().bind(
- scene.widthProperty().subtract(10)
- );
- lnEX[4].endYProperty().bind(
- scene.heightProperty().subtract(10)
- );
- lnEX[4].endXProperty().bind(
- scene.widthProperty().subtract(
- scene.widthProperty().add(10)
- )
- );
- stglines.show();
- }
- public static void main(String[] args) {
- Fxone.launch(args);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment