Advertisement
Pavle_nis

Java1

Jun 16th, 2017
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 14.23 KB | None | 0 0
  1. FadeTransition fade = new FadeTransition();
  2.         fade.setNode(krug);
  3.         fade.setAutoReverse(false);
  4.         fade.setFromValue(0);
  5.         fade.setToValue(1);
  6.         fade.setCycleCount(1);
  7.         fade.setDuration(Duration.seconds(5));
  8.         fade.play();
  9.  
  10.  
  11. 2
  12.                
  13.         scena.setOnKeyPressed(e-> {
  14.             if (e.getCode() == KeyCode.NUMPAD8) {
  15.                
  16.             } else if (e.getCode() == KeyCode.NUMPAD5) {
  17.                
  18.             } else if (e.getCode() == KeyCode.NUMPAD2) {
  19.                
  20.             }
  21.  
  22.  
  23.  
  24. public static void main(String[] args) {
  25.         launch(args);
  26.     }
  27.    
  28.     public void animacija(Circle krug)
  29.     {
  30.        
  31.     }
  32. /*
  33.  * To change this license header, choose License Headers in Project Properties.
  34.  * To change this template file, choose Tools | Templates
  35.  * and open the template in the editor.
  36.  */
  37. package fade;
  38.  
  39. import javafx.animation.FadeTransition;
  40. import javafx.animation.Timeline;
  41. import javafx.application.Application;
  42. import javafx.event.ActionEvent;
  43. import javafx.event.EventHandler;
  44. import javafx.scene.Scene;
  45. import javafx.scene.control.Button;
  46. import javafx.scene.layout.Pane;
  47. import javafx.scene.layout.StackPane;
  48. import javafx.scene.paint.Color;
  49. import javafx.scene.shape.Circle;
  50. import javafx.stage.Stage;
  51. import javafx.util.Duration;
  52.  
  53. /**
  54.  *
  55.  * @author profesor
  56.  */
  57. public class Fade extends Application {
  58.    
  59.     @Override
  60.     public void start(Stage primaryStage) {
  61.         Circle krug=new Circle();
  62.         krug.setRadius(50);
  63.         krug.setFill(Color.RED);
  64.         krug.setLayoutX(250);
  65.         krug.setLayoutY(250);
  66.         Pane p=new Pane();
  67.        
  68.         p.getChildren().add(krug);
  69.  
  70.         Button start=new Button("Start");
  71.         Button pauza=new Button("Pauza");
  72.         p.getChildren().addAll(start,pauza);
  73.         start.setLayoutX(50);
  74.         start.setLayoutY(50);
  75.        
  76.         pauza.setLayoutX(150);
  77.         pauza.setLayoutY(50);
  78.        
  79.         FadeTransition fade=new FadeTransition();
  80.         fade.setNode(krug);
  81.         fade.setAutoReverse(true);
  82.         fade.setFromValue(1);        
  83.         fade.setToValue(0);
  84.         fade.setCycleCount(Timeline.INDEFINITE);
  85.         fade.setDuration(Duration.seconds(1));        
  86.        
  87.         primaryStage.setScene(new Scene(p,500,500));
  88.         primaryStage.show();
  89.        
  90.         start.setOnAction(e->{
  91.             fade.play();
  92.         });
  93.         pauza.setOnAction(e->{
  94.             fade.pause();
  95.         });
  96.        
  97.     }
  98.  
  99.     /**
  100.      * @param args the command line arguments
  101.      */
  102.     public static void main(String[] args) {
  103.         launch(args);
  104.     }
  105.    
  106. }
  107.  
  108.  
  109.  
  110.  
  111. /*
  112.  * To change this license header, choose License Headers in Project Properties.
  113.  * To change this template file, choose Tools | Templates
  114.  * and open the template in the editor.
  115.  */
  116. package primer1;
  117.  
  118. import java.io.File;
  119. import java.util.Scanner;
  120. import javafx.application.Application;
  121. import javafx.event.ActionEvent;
  122. import javafx.event.EventHandler;
  123. import javafx.scene.Scene;
  124. import javafx.scene.control.Button;
  125. import javafx.scene.layout.Pane;
  126. import javafx.scene.layout.StackPane;
  127. import javafx.stage.FileChooser;
  128. import javafx.stage.FileChooser.ExtensionFilter;
  129. import javafx.stage.Stage;
  130.  
  131. /**
  132.  *
  133.  * @author profesor
  134.  */
  135. public class Primer1 extends Application {
  136.    
  137.     @Override
  138.     public void start(Stage primaryStage) {
  139.         Pane p=new Pane();
  140.         Button dugme=new Button("Otvori Fajl");
  141.         p.getChildren().add(dugme);
  142.         primaryStage.setScene(new Scene(p,500,500));
  143.         primaryStage.show();
  144.        
  145.         dugme.setOnAction(e->{
  146.             FileChooser fc=new FileChooser();
  147.             fc.getExtensionFilters().addAll(new ExtensionFilter("Text","*.txt"));
  148.             File izabranFajl=fc.showOpenDialog(null);
  149.             if(izabranFajl!=null)
  150.             {
  151.                 try
  152.                 {
  153.                     Scanner scanner=new Scanner(izabranFajl);
  154.                     while(scanner.hasNextLine())
  155.                     {
  156.                         System.out.println(scanner.nextLine());
  157.                     }
  158.                     scanner.close();
  159.                 }
  160.                 catch(Exception ex)
  161.                 {
  162.                     ex.printStackTrace();
  163.                 }
  164.                
  165.             }
  166.         });
  167.     }
  168.  
  169.     /**
  170.      * @param args the command line arguments
  171.      */
  172.     public static void main(String[] args) {
  173.         launch(args);
  174.     }
  175.    
  176. }
  177.  
  178.  
  179.  
  180.  
  181.  
  182. /*
  183.  * To change this license header, choose License Headers in Project Properties.
  184.  * To change this template file, choose Tools | Templates
  185.  * and open the template in the editor.
  186.  */
  187.  
  188.  
  189. MRK
  190.  * To change this license header, choose License Headers in Project Properties.
  191.  * To change this template file, choose Tools | Templates
  192.  * and open the template in the editor.
  193.  */
  194. package primer1;
  195.  
  196. import javafx.application.Application;
  197. import javafx.event.ActionEvent;
  198. import javafx.event.EventHandler;
  199. import javafx.scene.Scene;
  200. import javafx.scene.control.Button;
  201. import javafx.scene.layout.Pane;
  202. import javafx.scene.layout.StackPane;
  203. import javafx.stage.Stage;
  204.  
  205. /**
  206.  *
  207.  * @author student
  208.  */
  209. public class Primer1 extends Application {
  210.    
  211.     @Override
  212.     public void start(Stage primaryStage) {
  213.        Pane p=new Pane();
  214.        Button dugme=new Button("Otvori Fajl");
  215.        p.getChildren().add(dugme);
  216.        primaryStage.setScene(new Scene(p,500,500));
  217.        primaryStage.show();
  218.        
  219.        
  220.        dugme.setOnAction(e->{
  221.            FileChosser fc=new FileChooser();
  222.            fc.getExtensionFilters().addAll(new ExtensionFilter("Text","*.txt"));
  223.            File izabranFajl=fc.showOpenDialog(null);
  224.            if(izabranjFajl!=null)
  225.            {
  226.                try
  227.                {
  228.                   Scanner scanner=new Scanner(izbranFajl);
  229.                  
  230.                }
  231.                catch(Exception ex)
  232.                {
  233.                    
  234.                }
  235.            }
  236.        })
  237.                
  238.     }
  239.    
  240.    
  241.   ======================================================================
  242.   package semafor;
  243.  
  244. import javafx.animation.FadeTransition;
  245. import javafx.application.Application;
  246. import javafx.scene.Scene;
  247. import javafx.scene.input.KeyCode;
  248. import javafx.scene.layout.Pane;
  249. import javafx.scene.paint.Color;
  250. import javafx.scene.shape.Circle;
  251. import javafx.scene.shape.Rectangle;
  252. import javafx.stage.Stage;
  253. import javafx.util.Duration;
  254.  
  255. public class Semafor extends Application {
  256.    
  257.     @Override
  258.     public void start(Stage primaryStage) {
  259.         Pane p = new Pane();
  260.         Rectangle prav = new Rectangle();
  261.         Rectangle pole = new Rectangle();
  262.         Circle circ = new Circle();
  263.         Circle circ1 = new Circle();
  264.         Circle circ2 = new Circle();
  265.        
  266.         circ.setRadius(50);
  267.         circ1.setRadius(50);
  268.         circ2.setRadius(50);
  269.        
  270.         circ.setFill(Color.RED);
  271.         circ1.setFill(Color.YELLOW);
  272.         circ2.setFill(Color.GREEN);
  273.        
  274.         circ.setLayoutX(250);
  275.         circ.setLayoutY(135);
  276.         circ1.setLayoutX(250);
  277.         circ1.setLayoutY(250);
  278.         circ2.setLayoutX(250);
  279.         circ2.setLayoutY(365);
  280.        
  281.         pole.setWidth(15);
  282.         pole.setHeight(100);
  283.         pole.setLayoutX(242);
  284.         pole.setLayoutY(425);
  285.         pole.setFill(Color.BLACK);
  286.        
  287.         prav.setWidth(150);
  288.         prav.setHeight(350);
  289.         prav.setLayoutX(175);
  290.         prav.setLayoutY(75);
  291.         prav.setStrokeWidth(5);
  292.         prav.setStroke(Color.BLACK);
  293.         prav.setFill(Color.TRANSPARENT);
  294.        
  295.         p.getChildren().addAll(prav,circ,circ1,circ2,pole);
  296.        
  297.         Scene scena = new Scene(p,500,500);
  298.        
  299.         primaryStage.setScene(scena);
  300.         primaryStage.setResizable(false);
  301.         primaryStage.show();
  302.        
  303.         scena.setOnKeyPressed(e-> {
  304.             if (e.getCode() == KeyCode.NUMPAD8) {
  305.                 animacija(circ);
  306.             } else if (e.getCode() == KeyCode.NUMPAD5) {
  307.                 animacija(circ1);
  308.             } else if (e.getCode() == KeyCode.NUMPAD2) {
  309.                 animacija(circ2);
  310.             }
  311.         });
  312.     }
  313.  
  314.     public static void main(String[] args) {
  315.         launch(args);
  316.     }
  317.     public void animacija(Circle krug){
  318.         FadeTransition fade = new FadeTransition();
  319.         fade.setNode(krug);
  320.         fade.setAutoReverse(false);
  321.         fade.setFromValue(0);
  322.         fade.setToValue(1);
  323.         fade.setCycleCount(1);
  324.         fade.setDuration(Duration.seconds(1));
  325.         fade.play();
  326.     }
  327. }
  328.  
  329.  
  330. //////////////////////////CEO SEMAFOR ! ! !
  331.  
  332.  
  333.  package semafor;
  334.  
  335. import javafx.animation.FadeTransition;
  336. import javafx.application.Application;
  337. import javafx.scene.Scene;
  338. import javafx.scene.input.KeyCode;
  339. import javafx.scene.layout.Pane;
  340. import javafx.scene.paint.Color;
  341. import javafx.scene.shape.Circle;
  342. import javafx.scene.shape.Rectangle;
  343. import javafx.stage.Stage;
  344. import javafx.util.Duration;
  345.  
  346. public class Semafor extends Application {
  347.    
  348.     @Override
  349.     public void start(Stage primaryStage) {
  350.         Pane p = new Pane();
  351.         Rectangle prav = new Rectangle();
  352.         Rectangle pole = new Rectangle();
  353.         Circle circ = new Circle();
  354.         Circle circ1 = new Circle();
  355.         Circle circ2 = new Circle();
  356.         circ.setVisible(false);
  357.         circ1.setVisible(false);
  358.         circ2.setVisible(false);
  359.        
  360.        
  361.         circ.setRadius(50);
  362.         circ1.setRadius(50);
  363.         circ2.setRadius(50);
  364.        
  365.         circ.setFill(Color.RED);
  366.         circ1.setFill(Color.YELLOW);
  367.         circ2.setFill(Color.GREEN);
  368.        
  369.         circ.setLayoutX(250);
  370.         circ.setLayoutY(135);
  371.         circ1.setLayoutX(250);
  372.         circ1.setLayoutY(250);
  373.         circ2.setLayoutX(250);
  374.         circ2.setLayoutY(365);
  375.        
  376.         pole.setWidth(15);
  377.         pole.setHeight(100);
  378.         pole.setLayoutX(242);
  379.         pole.setLayoutY(425);
  380.         pole.setFill(Color.BLACK);
  381.        
  382.         prav.setWidth(150);
  383.         prav.setHeight(350);
  384.         prav.setLayoutX(175);
  385.         prav.setLayoutY(75);
  386.         prav.setStrokeWidth(5);
  387.         prav.setStroke(Color.BLACK);
  388.         prav.setFill(Color.TRANSPARENT);
  389.        
  390.         p.getChildren().addAll(prav,circ,circ1,circ2,pole);
  391.        
  392.         Scene scena = new Scene(p,500,500);
  393.        
  394.         primaryStage.setScene(scena);
  395.         primaryStage.setResizable(false);
  396.         primaryStage.show();
  397.        
  398.         scena.setOnKeyPressed(e-> {
  399.             if (e.getCode() == KeyCode.NUMPAD8) {
  400.                 circ.setVisible(true);
  401.                 circ1.setVisible(false);
  402.                 circ2.setVisible(false);
  403.                 animacija(circ);
  404.             } else if (e.getCode() == KeyCode.NUMPAD5) {
  405.                 circ.setVisible(false);
  406.                 circ1.setVisible(true);
  407.                 circ2.setVisible(false);
  408.                 animacija(circ1);
  409.             } else if (e.getCode() == KeyCode.NUMPAD2) {
  410.                 circ.setVisible(false);
  411.                 circ1.setVisible(false);
  412.                 circ2.setVisible(true);
  413.                 animacija(circ2);
  414.             }
  415.         });
  416.     }
  417.  
  418.     public static void main(String[] args) {
  419.         launch(args);
  420.     }
  421.     public void animacija(Circle krug){
  422.         FadeTransition fade = new FadeTransition();
  423.         fade.setNode(krug);
  424.         fade.setAutoReverse(false);
  425.         fade.setFromValue(0);
  426.         fade.setToValue(1);
  427.         fade.setCycleCount(1);
  428.         fade.setDuration(Duration.seconds(1));
  429.         fade.play();
  430.     }
  431. }
  432.  
  433. Daddy Roadhog shoves his big meat into your tight anus
  434.  
  435.  
  436. //////////////////////////// MEDIA PLAYER
  437.  
  438.  
  439.  package media;
  440.  
  441.  
  442. import javafx.application.Application;
  443. import javafx.stage.Stage;
  444. import javafx.geometry.Pos;
  445. import javafx.scene.Scene;
  446. import javafx.scene.control.Button;
  447. import javafx.scene.control.Label;
  448. import javafx.scene.control.Slider;
  449. import javafx.scene.layout.BorderPane;
  450. import javafx.scene.layout.HBox;
  451. import javafx.scene.layout.Region;
  452. import javafx.scene.media.Media;
  453. import javafx.scene.media.MediaPlayer;
  454. import javafx.scene.media.MediaView;
  455. import javafx.util.Duration;
  456.  
  457. public class Mediaa extends Application {
  458.  
  459.     private static final String MEDIA_URL
  460.             = "http://cs.armstrong.edu/liang/common/sample.mp4";
  461.  
  462.     @Override // Override the start method in the Application class
  463.     public void start(Stage primaryStage) {
  464.         Media media = new Media(MEDIA_URL);
  465.         MediaPlayer mediaPlayer = new MediaPlayer(media);
  466.         MediaView mediaView = new MediaView(mediaPlayer);
  467.         Button playButton = new Button(">");
  468.         playButton.setOnAction(e -> {
  469.             if (playButton.getText().equals(">")) {
  470.                 mediaPlayer.play();
  471.                 playButton.setText("||");
  472.             } else {
  473.                 mediaPlayer.pause();
  474.                 playButton.setText(">");
  475.             }
  476.         });
  477.         Button rewindButton = new Button("<<");
  478.         rewindButton.setOnAction(e -> mediaPlayer.seek(Duration.ZERO));
  479.         Slider slVolume = new Slider();
  480.         slVolume.setPrefWidth(150);
  481.         slVolume.setMaxWidth(Region.USE_PREF_SIZE);
  482.         slVolume.setMinWidth(30);
  483.         slVolume.setValue(50);
  484.         mediaPlayer.volumeProperty().bind(
  485.                 slVolume.valueProperty().divide(100));
  486.         HBox hBox = new HBox(10);
  487.         hBox.setAlignment(Pos.CENTER);
  488.         hBox.getChildren().addAll(playButton, rewindButton,
  489.                 new Label("Volume"), slVolume);
  490.         BorderPane pane = new BorderPane();
  491.         pane.setCenter(mediaView);
  492.         pane.setBottom(hBox);
  493. // Create a scene and place it in the stage
  494.         Scene scene = new Scene(pane, 650, 500);
  495.         primaryStage.setTitle("MediaDemo"); // Set the stage title
  496.         primaryStage.setScene(scene); // Place the scene in the stage
  497.         primaryStage.show(); // Display the stage
  498.     }
  499.  
  500.     /**
  501.      * The main method is only needed for the IDE with limited JavaFX support.
  502.      * Not needed for running from the command line.
  503.      */
  504.     public static void main(String[] args) {
  505.         launch(args);
  506.     }
  507. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement