miyago

Untitled

Oct 15th, 2019
407
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.52 KB | None | 0 0
  1. package application;
  2.    
  3. import javax.swing.border.LineBorder;
  4.  
  5. import javafx.application.Application;
  6. import javafx.collections.ObservableList;
  7. import javafx.event.ActionEvent;
  8. import javafx.event.EventHandler;
  9. import javafx.geometry.Insets;
  10. import javafx.stage.Stage;
  11. import javafx.scene.Scene;
  12. import javafx.scene.control.Button;
  13. import javafx.scene.control.CheckMenuItem;
  14. import javafx.scene.control.Label;
  15. import javafx.scene.control.Menu;
  16. import javafx.scene.control.MenuBar;
  17. import javafx.scene.control.MenuItem;
  18. import javafx.scene.control.TextField;
  19. import javafx.scene.image.Image;
  20. import javafx.scene.image.ImageView;
  21. import javafx.scene.layout.Border;
  22. import javafx.scene.layout.BorderPane;
  23. import javafx.scene.layout.StackPane;
  24. import javafx.scene.layout.VBox;
  25. import javafx.scene.paint.Color;
  26.  
  27.  
  28. public class Main extends Application implements EventHandler<ActionEvent> {
  29.    
  30.     Button button;
  31.    
  32.    
  33.     public void start(Stage primaryStage) {
  34.        
  35.         primaryStage.setTitle("TITLE OF THE WINDOW");
  36.         button = new Button("HEJ");
  37.        
  38.         button.setOnAction(e -> primaryStage.hide());
  39.        
  40.         BorderPane layout = new BorderPane();
  41.        
  42.          
  43.         final Label open = new Label();
  44.          MenuBar menuBar = new MenuBar();
  45.          
  46.             // --- Menu File
  47.             Menu menuFile = new Menu("File");
  48.                 MenuItem openImage = new MenuItem("Open file", open);
  49.                 openImage.setOnAction(e->primaryStage.hide());
  50.                 menuFile.getItems().add(openImage);
  51.      
  52.             // --- Menu Edit
  53.             Menu menuEdit = new Menu("Edit");
  54.            
  55.      
  56.             // --- Menu View
  57.             Menu menuView = new Menu("View");
  58.      
  59.             menuBar.getMenus().addAll(menuFile, menuEdit, menuView);
  60.            
  61.            
  62.            
  63.             // Create Image and ImageView objects
  64.             Image image = new Image("application/lab4.png");
  65.             ImageView imageView = new ImageView();
  66.             imageView.setImage(image);
  67.                        
  68.             //creating a text field
  69.             TextField textField = new TextField();      
  70.            
  71.             //Creating the play button
  72.             Button playButton = new Button("Play");
  73.            
  74.             //Creating the stop button
  75.             Button stopButton = new Button("stop");
  76.            
  77.             //Instantiating the VBox class  
  78.             VBox vBox = new VBox();  
  79.            
  80.             //Setting the space between the nodes of a VBox pane
  81.             vBox.setSpacing(10);  
  82.            
  83.             //Setting the margin to the nodes
  84.             vBox.setMargin(textField, new Insets(20, 20, 20, 20));  
  85.             vBox.setMargin(playButton, new Insets(20, 20, 20, 20));
  86.             vBox.setMargin(stopButton, new Insets(20, 20, 20, 20));  
  87.            
  88.             //retrieving the observable list of the VBox
  89.             ObservableList list = vBox.getChildren();
  90.            
  91.             //Adding all the nodes to the observable list
  92.             list.addAll(textField, playButton, stopButton);
  93.            
  94.             // BorderPane
  95.            
  96.            
  97.            
  98.             layout.setTop(menuBar);
  99.             layout.setRight(imageView);
  100.             layout.setLeft(vBox);
  101.             layout.setBottom(button);
  102.    
  103.      
  104.        
  105.         // Display image on screen
  106.  
  107.        
  108.        
  109.         Scene scene = new Scene(layout, 800,450);
  110.         primaryStage.setScene(scene);
  111.         primaryStage.show();
  112.        
  113.     }
  114.    
  115.     public static void main(String[] args) {
  116.         launch(args);
  117.     }
  118.  
  119.     @Override
  120.     public void handle(ActionEvent arg0) {
  121.         // TODO Auto-generated method stub
  122.        
  123.     }
  124.  
  125.  
  126.  
  127.    
  128.    
  129.    
  130. }
  131. @FunctionalInterface
  132. interface lambaExp {
  133.     int add(int a,int b);  
  134. }
Advertisement
Add Comment
Please, Sign In to add comment