package application;
import javax.swing.border.LineBorder;
import javafx.application.Application;
import javafx.collections.ObservableList;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.geometry.Insets;
import javafx.stage.Stage;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.CheckMenuItem;
import javafx.scene.control.Label;
import javafx.scene.control.Menu;
import javafx.scene.control.MenuBar;
import javafx.scene.control.MenuItem;
import javafx.scene.control.TextField;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.Border;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.StackPane;
import javafx.scene.layout.VBox;
import javafx.scene.paint.Color;
public class Main extends Application implements EventHandler<ActionEvent> {
Button button;
public void start(Stage primaryStage) {
primaryStage.setTitle("TITLE OF THE WINDOW");
button = new Button("HEJ");
button.setOnAction(e -> primaryStage.hide());
BorderPane layout = new BorderPane();
final Label open = new Label();
MenuBar menuBar = new MenuBar();
// --- Menu File
Menu menuFile = new Menu("File");
MenuItem openImage = new MenuItem("Open file", open);
openImage.setOnAction(e->primaryStage.hide());
menuFile.getItems().add(openImage);
// --- Menu Edit
Menu menuEdit = new Menu("Edit");
// --- Menu View
Menu menuView = new Menu("View");
menuBar.getMenus().addAll(menuFile, menuEdit, menuView);
// Create Image and ImageView objects
Image image = new Image("application/lab4.png");
ImageView imageView = new ImageView();
imageView.setImage(image);
//creating a text field
TextField textField = new TextField();
//Creating the play button
Button playButton = new Button("Play");
//Creating the stop button
Button stopButton = new Button("stop");
//Instantiating the VBox class
VBox vBox = new VBox();
//Setting the space between the nodes of a VBox pane
vBox.setSpacing(10);
//Setting the margin to the nodes
vBox.setMargin(textField, new Insets(20, 20, 20, 20));
vBox.setMargin(playButton, new Insets(20, 20, 20, 20));
vBox.setMargin(stopButton, new Insets(20, 20, 20, 20));
//retrieving the observable list of the VBox
ObservableList list = vBox.getChildren();
//Adding all the nodes to the observable list
list.addAll(textField, playButton, stopButton);
// BorderPane
layout.setTop(menuBar);
layout.setRight(imageView);
layout.setLeft(vBox);
layout.setBottom(button);
// Display image on screen
Scene scene = new Scene(layout, 800,450);
primaryStage.setScene(scene);
primaryStage.show();
}
public static void main(String[] args) {
launch(args);
}
@Override
public void handle(ActionEvent arg0) {
// TODO Auto-generated method stub
}
}
@FunctionalInterface
interface lambaExp {
int add(int a,int b);
}
Comments