Advertisement
shmolf

EssentialOils_InfoPane

Sep 1st, 2013
199
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.97 KB | None | 0 0
  1. public class InfoPane extends BorderPane{
  2.    
  3.     GridPane infoGrid;
  4.    
  5.     Oil oil;
  6.     Label name;
  7.     Label botanicalName;
  8.     ArrayList<Label> compatibleOils;
  9.     ArrayList<Label> ailments;
  10.     ArrayList<Label> warnings;
  11.     Label notes;
  12.    
  13.     public InfoPane()
  14.     {
  15.         infoGrid = new GridPane();
  16.         oil = new Oil();
  17.         name = new Label();
  18.         botanicalName = new Label();
  19.         compatibleOils = new ArrayList<>();
  20.         ailments = new ArrayList<>();
  21.         warnings = new ArrayList<>();
  22.         notes = new Label();
  23.     }
  24.    
  25.     public void setOil(Oil setOil)
  26.     {
  27.         oil = setOil;
  28.         name.setText("Name: " + oil.getName());
  29.         botanicalName.setText("Botanical Name: " + oil.getBotanicalName());
  30.         compatibleOils.clear();
  31.         for(int i = 0; i < oil.getCompatibleOilSize(); i++){compatibleOils.add(new Label(oil.getOil(i).getName()));}
  32.         ailments.clear();
  33.         for(int i = 0; i < oil.getAilmentSize(); i++){ailments.add(new Label(oil.getOil(i).getName()));}
  34.         warnings.clear();
  35.         for(int i = 0; i < oil.getWarningSize(); i++){warnings.add(new Label(oil.getOil(i).getName()));}
  36.         placeItems();
  37.     }
  38.    
  39.     private void placeItems()
  40.     {
  41.         int x = 0; int y = 0;
  42.         this.setCenter(infoGrid);
  43.         infoGrid.add(name, x, y);
  44.         infoGrid.add(botanicalName, x + 1, y); y++;
  45.         infoGrid.add(new Label("Compatible Oils:"), x, y); y++;
  46.         for(int i = 0; i < compatibleOils.size(); i ++)
  47.         {
  48.             infoGrid.add(compatibleOils.get(i),x+1,y);y++;
  49.         }
  50.         infoGrid.add(new Label("Ailments:"), x, y); y++;
  51.         for(int i = 0; i < ailments.size(); i ++)
  52.         {
  53.             infoGrid.add(ailments.get(i),x+1,y);y++;
  54.         }
  55.         infoGrid.add(new Label("Warnings:"), x, y); y++;
  56.         for(int i = 0; i < warnings.size(); i ++)
  57.         {
  58.             infoGrid.add(warnings.get(i),x+1,y);y++;
  59.         }
  60.     }
  61.    
  62.    
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement