SHARE
TWEET

Untitled

a guest Jan 22nd, 2020 66 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package sample;
  2.  
  3. import com.jfoenix.controls.JFXComboBox;
  4. import javafx.application.Platform;
  5. import javafx.fxml.FXML;
  6. import javafx.scene.control.Button;
  7. import javafx.scene.control.Label;
  8. import javafx.scene.control.MenuItem;
  9. import javafx.scene.layout.VBox;
  10. import javafx.stage.DirectoryChooser;
  11. import javafx.stage.Stage;
  12.  
  13. import javax.swing.*;
  14. import java.awt.*;
  15. import java.io.File;
  16.  
  17. import java.io.IOException;
  18. import java.io.PrintStream;
  19. import java.net.URI;
  20. import java.net.URISyntaxException;
  21. import java.time.LocalDate;
  22. import java.util.regex.Pattern;
  23.  
  24.  
  25.  
  26. public class Controller extends Main {
  27.  
  28.     @FXML
  29.     public VBox vBox;
  30.  
  31.     @FXML
  32.     public Button btnDirectoryChooser;
  33.  
  34.     @FXML
  35.     public Label lblCopyright;
  36.  
  37.     @FXML
  38.     public Button btnRename;
  39.  
  40.     @FXML
  41.     public Button btnGithub;
  42.  
  43.     @FXML
  44.     public Label lblDirectory;
  45.  
  46.     @FXML
  47.     MenuItem menuBar;
  48.  
  49.     @FXML
  50.     MenuItem menuBarMax;
  51.  
  52.     @FXML
  53.     JFXComboBox<String> cBoxFileType;
  54.  
  55.     private String now = LocalDate.now().toString().replaceAll("-","");
  56.     private Stage primaryStage;
  57.     private boolean directoryChosen;
  58.     private static final Pattern INVALID_CHARS_PATTERN =
  59.             Pattern.compile("[^~#@*+%{}<>\\[\\]|/\"\\_^]*");
  60.     private String[] fileTypes = {".txt",".png",".jpg",".jpeg",".gif"};
  61.  
  62.  
  63.     public void initialize() {
  64.         setPrimaryStage(primaryStage);
  65.         addItemsToList();
  66.         cBoxFileType.setValue(".txt");
  67.     }
  68.  
  69.     private void setPrimaryStage(Stage primaryStage) {
  70.         this.primaryStage = primaryStage;
  71.     }
  72.  
  73.     public void closeApp() {
  74.         Platform.exit();
  75.     }
  76.  
  77.     private void addItemsToList(){
  78.         for (String fileType : fileTypes) {
  79.             cBoxFileType.getItems().add(fileType);
  80.         }
  81.     }
  82.  
  83.     public void maximize(){
  84.       primaryStage.setMaximized(true);
  85.     }
  86.  
  87.     public void browse() throws URISyntaxException, IOException {
  88.         if (Desktop.isDesktopSupported() && Desktop.getDesktop().isSupported(Desktop.Action.BROWSE)) {
  89.             Desktop.getDesktop().browse(new URI("https://github.com/Yannick-Driessens"));
  90.         }
  91.     }
  92.  
  93.     public void setDirectory() {
  94.         DirectoryChooser directoryChooser = new DirectoryChooser();
  95.         File selectedDirectory = directoryChooser.showDialog(primaryStage);
  96.         directoryChosen = true;
  97.  
  98.         if (selectedDirectory == null) {
  99.             JOptionPane.showMessageDialog(null, "Je hebt geen directory gekozen!");
  100.             directoryChosen = false;
  101.         } else {
  102.             lblDirectory.setText("Gekozen directory: " + selectedDirectory.getAbsolutePath());
  103.         }
  104.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top