Advertisement
shmolf

EssentialOils_MainClass

Sep 1st, 2013
324
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.26 KB | None | 0 0
  1. public class EssentialOils extends Application {
  2.     File file;
  3.     DataFile dataFile;
  4.     ComboBox<Oil> oilName;
  5.     ObservableList<Oil> oilList;
  6.     InfoPane infoPane;
  7.    
  8.    
  9.     @Override
  10.     public void start(Stage primaryStage) {
  11.         dataFile = new DataFile();
  12.         oilList = FXCollections.observableArrayList();
  13.         infoPane = new InfoPane();
  14.        
  15.         VBox mainButtons = new VBox();
  16.         mainButtons.setSpacing(9.0);
  17.         Button openButton = new OpenFile(this,dataFile);
  18.         Button exitButton = new ExitButton();
  19.         mainButtons.getChildren().addAll(openButton, exitButton);
  20.        
  21.         BorderPane root = new BorderPane();
  22.         root.setRight(mainButtons);
  23.        
  24.         oilName = new ComboBox<>();
  25.         oilName.setItems(oilList);
  26.         oilName.setPrefWidth(300);
  27.         new AutoCompleteComboBoxListener(oilName);
  28.        
  29.         Button loadButton = new Button("Load");
  30.         loadButton.setOnAction(new EventHandler<ActionEvent>(){
  31.             @Override
  32.             public void handle(ActionEvent arg0) {
  33.                 infoPane.setOil(oilName.getValue());
  34.             }
  35.         });
  36.        
  37.        
  38.        
  39.         VBox leftSide = new VBox();
  40.         leftSide.getChildren().addAll(oilName, loadButton);
  41.        
  42.         root.setLeft(leftSide);
  43.         root.setCenter(infoPane);
  44.        
  45.         Scene scene = new Scene(root, 500, 400);
  46.        
  47.         primaryStage.setTitle("Essential Oil Resource");
  48.         primaryStage.setScene(scene);
  49.         primaryStage.show();
  50.     }
  51.    
  52.     public void generateOilList()
  53.     {
  54.             System.out.println("Bout to generate");
  55.         int n = dataFile.getOils().size();
  56.         for(int i = 0; i < n; i++)
  57.         {
  58.             oilList.add(dataFile.getOil(i));
  59.             System.out.println(oilList.get(i));
  60.         }
  61.     }
  62.  
  63.     /**
  64.      * The main() method is ignored in correctly deployed JavaFX application.
  65.      * main() serves only as fallback in case the application can not be
  66.      * launched through deployment artifacts, e.g., in IDEs with limited FX
  67.      * support. NetBeans ignores main().
  68.      *
  69.      * @param args the command line arguments
  70.      */
  71.     public static void main(String[] args) {
  72.         launch(args);
  73.     }
  74. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement