Guest User

bind_In_Line_JFX

a guest
Aug 3rd, 2014
302
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.67 KB | None | 0 0
  1. /*
  2.  * To change this license header, choose License Headers in Project Properties.
  3.  * To change this template file, choose Tools | Templates
  4.  * and open the template in the editor.
  5.  */
  6.  
  7. package fxone;
  8.  
  9. import javafx.application.Application;
  10. import javafx.scene.Group;
  11. import javafx.scene.Scene;
  12. import javafx.scene.paint.Color;
  13. import javafx.scene.shape.Line;
  14. import javafx.stage.Stage;
  15.  
  16. /**
  17.  *
  18.  *  knb
  19. bem10jfx.blogspot.com
  20. numagrandeviagem.blogspot.com
  21.  */
  22. public class lines extends Application{
  23.     @Override
  24.     public void start(Stage stglines) throws Exception {
  25.         Group go=new Group();
  26.         Scene scene=new Scene(go,300,300,Color.ALICEBLUE);
  27.         stglines.setScene(scene);
  28.        
  29.         Line lnEX[]=new Line[6];
  30.         for (int i = 1; i < 6; i++) {
  31.             lnEX[i]=new Line();
  32.         go.getChildren().add(lnEX[i]);
  33.         }
  34.     /* binds tem as características de receber
  35.        dados inteiros e trabalhá-los de maneira
  36.        que otimize os retornos de valores....
  37.         tambem funcionam de forma que se  algum WindowsEvent for iniciado no programa
  38.         como Maximizar , restaurar, ou mover as propriedades de dimenções  ,
  39.         os binds irão sincronizar de acordo com as dimenções e a localidades do obgeto
  40.         */
  41.          /*bind 1 inicia a linha do ponto 0 (zero) ate a extremidade da scene*/
  42.         lnEX[1].setLayoutX(10);
  43.         lnEX[1].setLayoutY(20);
  44.         lnEX[1].setStartX(0);
  45.         lnEX[1].setStartY(20);
  46.         lnEX[1].endXProperty().bind(scene.widthProperty());
  47.         lnEX[1].setEndY(20);
  48.        
  49.         /*bind 2 cor vermelho inicia a linha o LayoutY no
  50.         ponto 25 e o x no Width 30 utilizando o bind*/
  51.        
  52.         lnEX[2].layoutXProperty().bind(scene.widthProperty().divide(10));
  53.         lnEX[2].layoutYProperty().bind(scene.heightProperty().divide(35));
  54.         lnEX[2].setStartY(20);
  55.         lnEX[2].setStartX(1);
  56.         lnEX[2].setEndY(20);
  57.         lnEX[2].setEndX(220);
  58.         lnEX[2].setStroke(Color.RED);
  59.        
  60.         /*bind3 retornando bind
  61.         lnEX[3].setStroke(Color.GREENYELLOW);
  62.        
  63.         lnEX[3].setStartY(scene.getHeight()-scene.getHeight());
  64.         lnEX[3].setStartX(scene.getWidth()-scene.getWidth());
  65.         lnEX[3].setEndY(scene.getHeight());
  66.         lnEX[3].setEndX(scene.getWidth());
  67.         */
  68.         lnEX[3].setStroke(Color.GREENYELLOW);
  69.        
  70.         lnEX[3].startYProperty().bind(
  71.                 scene.heightProperty().subtract(
  72.                         scene.heightProperty().add(20)
  73.                 )
  74.         );
  75.        
  76.         lnEX[3].startXProperty().bind(
  77.                 scene.widthProperty().divide(
  78.                         scene.widthProperty().add(10)
  79.                 )
  80.         );
  81.         lnEX[3].endYProperty().bind(scene.heightProperty().subtract(10));
  82.         lnEX[3].endXProperty().bind(scene.widthProperty().subtract(10));
  83.          
  84.         /*bind4 retornando bind
  85.         */
  86.         lnEX[4].setStroke(Color.BLUEVIOLET);
  87.        
  88.         lnEX[4].startYProperty().bind(
  89.                 scene.heightProperty().subtract(scene.heightProperty().add(10))
  90.                );
  91.        
  92.         lnEX[4].startXProperty().bind(
  93.                 scene.widthProperty().subtract(10)
  94.                  );
  95.        
  96.         lnEX[4].endYProperty().bind(
  97.                 scene.heightProperty().subtract(10)
  98.         );
  99.        
  100.         lnEX[4].endXProperty().bind(
  101.                 scene.widthProperty().subtract(
  102.                         scene.widthProperty().add(10)
  103.                 )
  104.         );
  105.        
  106.         stglines.show();
  107.     }
  108.    
  109.     public static void main(String[] args) {
  110.         Fxone.launch(args);
  111.     }
  112. }
Advertisement
Add Comment
Please, Sign In to add comment