Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package readingExcel;
- import java.io.File;
- import javafx.application.Application;
- import javafx.geometry.Pos;
- import javafx.geometry.Rectangle2D;
- import javafx.scene.Group;
- import javafx.scene.Scene;
- import javafx.scene.layout.GridPane;
- import javafx.scene.layout.StackPane;
- import javafx.scene.paint.Color;
- import javafx.scene.shape.Circle;
- import javafx.scene.text.Font;
- import javafx.scene.text.FontWeight;
- import javafx.scene.text.Text;
- import javafx.stage.FileChooser;
- import javafx.stage.Screen;
- import javafx.stage.Stage;
- import javafx.event.ActionEvent;
- import javafx.event.EventHandler;
- import javafx.scene.control.Button;
- import javafx.scene.image.Image ;
- import javafx.scene.image.ImageView;
- public class GUI extends Application {
- private GridPane grid = new GridPane();
- private Button btn = new Button();
- @Override
- public void start(Stage primaryStage) {
- StackPane root = new StackPane();
- setBackGround(root);
- addImage();
- addGrid(root);
- addBtn(primaryStage);
- Scene scene = new Scene(root, 500, 400);
- primaryStage.setTitle("Read Excel File");
- primaryStage.setScene(scene);
- primaryStage.show();
- }
- public static void main(String[] args) {
- Application.launch(args);
- }
- private void addGrid(StackPane root) {
- grid.setAlignment(Pos.TOP_CENTER);
- grid.setHgap(10);
- grid.setVgap(10);
- grid.setMaxWidth(100);
- grid.setMaxHeight(100);
- grid.setPadding(new javafx.geometry.Insets(25, 25, 25, 25));
- Text text = new Text("Select Excel File : ");
- text.setFont(Font.font("Tahoma", FontWeight.NORMAL, 15));
- text.toFront();
- grid.add(text, 1, 5, 2, 1);
- root.getChildren().add(grid);
- }
- private void addBtn(final Stage primaryStage) {
- btn.setText("Browse Files");
- btn.setOnAction(new EventHandler<ActionEvent>() {
- @Override
- public void handle(ActionEvent event) {
- FileChooser fileChooser = new FileChooser();
- fileChooser.setTitle("Open Resource File");
- File file = fileChooser.showOpenDialog(primaryStage);
- // if (file != null) {
- // openFile(file);
- // }
- }
- });
- grid.add(btn, 1, 5, 5, 8);
- }
- private void openFile(File file){
- }
- private void setBackGround(StackPane root) {
- Rectangle2D primaryScreenBounds = Screen.getPrimary().getVisualBounds();
- double x = primaryScreenBounds.getWidth();
- double y = primaryScreenBounds.getHeight();
- final Circle c = new Circle(x / 2, y / 2, 2 * x);
- c.setFill(Color.ORANGE);
- final Group g = new Group(c);
- root.getChildren().add(g);
- }
- private void addImage(){
- Image image = new Image("File:C:/Users/admin/Desktop/image.png");
- ImageView i = new ImageView(image);
- // i.setX(20);
- i.setFitHeight(130);
- i.setFitWidth(130);
- // i.setY(20);
- grid.add(i, 1,1);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement