├── FruitMarket ├── src │ ├── img │ │ ├── kiwi.png │ │ ├── banana.png │ │ ├── cherry.png │ │ ├── grapes.png │ │ ├── mango.png │ │ ├── orange.png │ │ ├── peach.png │ │ ├── coconut.png │ │ ├── ic_cart.png │ │ ├── ic_delivery.png │ │ ├── strawberry.png │ │ ├── watermelon.png │ │ └── ic_stopwatch.png │ ├── main │ │ ├── MyListener.java │ │ └── Main.java │ ├── model │ │ └── Fruit.java │ ├── values │ │ └── style.css │ ├── Controller │ │ ├── ItemController.java │ │ └── MarketController.java │ └── views │ │ ├── item.fxml │ │ └── market.fxml ├── Screenshot │ ├── image1.png │ ├── image2.PNG │ ├── image3.PNG │ └── image4.PNG ├── out │ └── production │ │ └── FruitMarket │ │ ├── img │ │ ├── banana.png │ │ ├── cherry.png │ │ ├── grapes.png │ │ ├── kiwi.png │ │ ├── mango.png │ │ ├── orange.png │ │ ├── peach.png │ │ ├── coconut.png │ │ ├── ic_cart.png │ │ ├── ic_delivery.png │ │ ├── strawberry.png │ │ ├── watermelon.png │ │ └── ic_stopwatch.png │ │ ├── main │ │ ├── Main.class │ │ └── MyListener.class │ │ ├── model │ │ └── Fruit.class │ │ ├── Controller │ │ ├── ItemController.class │ │ ├── MarketController.class │ │ └── MarketController$1.class │ │ ├── values │ │ └── style.css │ │ └── views │ │ ├── item.fxml │ │ └── market.fxml └── FruitMarket.iml └── README.md /FruitMarket/src/img/kiwi.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahmoudhamwi/Fruits-Market/HEAD/FruitMarket/src/img/kiwi.png -------------------------------------------------------------------------------- /FruitMarket/src/img/banana.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahmoudhamwi/Fruits-Market/HEAD/FruitMarket/src/img/banana.png -------------------------------------------------------------------------------- /FruitMarket/src/img/cherry.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahmoudhamwi/Fruits-Market/HEAD/FruitMarket/src/img/cherry.png -------------------------------------------------------------------------------- /FruitMarket/src/img/grapes.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahmoudhamwi/Fruits-Market/HEAD/FruitMarket/src/img/grapes.png -------------------------------------------------------------------------------- /FruitMarket/src/img/mango.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahmoudhamwi/Fruits-Market/HEAD/FruitMarket/src/img/mango.png -------------------------------------------------------------------------------- /FruitMarket/src/img/orange.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahmoudhamwi/Fruits-Market/HEAD/FruitMarket/src/img/orange.png -------------------------------------------------------------------------------- /FruitMarket/src/img/peach.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahmoudhamwi/Fruits-Market/HEAD/FruitMarket/src/img/peach.png -------------------------------------------------------------------------------- /FruitMarket/Screenshot/image1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahmoudhamwi/Fruits-Market/HEAD/FruitMarket/Screenshot/image1.png -------------------------------------------------------------------------------- /FruitMarket/Screenshot/image2.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahmoudhamwi/Fruits-Market/HEAD/FruitMarket/Screenshot/image2.PNG -------------------------------------------------------------------------------- /FruitMarket/Screenshot/image3.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahmoudhamwi/Fruits-Market/HEAD/FruitMarket/Screenshot/image3.PNG -------------------------------------------------------------------------------- /FruitMarket/Screenshot/image4.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahmoudhamwi/Fruits-Market/HEAD/FruitMarket/Screenshot/image4.PNG -------------------------------------------------------------------------------- /FruitMarket/src/img/coconut.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahmoudhamwi/Fruits-Market/HEAD/FruitMarket/src/img/coconut.png -------------------------------------------------------------------------------- /FruitMarket/src/img/ic_cart.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahmoudhamwi/Fruits-Market/HEAD/FruitMarket/src/img/ic_cart.png -------------------------------------------------------------------------------- /FruitMarket/src/img/ic_delivery.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahmoudhamwi/Fruits-Market/HEAD/FruitMarket/src/img/ic_delivery.png -------------------------------------------------------------------------------- /FruitMarket/src/img/strawberry.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahmoudhamwi/Fruits-Market/HEAD/FruitMarket/src/img/strawberry.png -------------------------------------------------------------------------------- /FruitMarket/src/img/watermelon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahmoudhamwi/Fruits-Market/HEAD/FruitMarket/src/img/watermelon.png -------------------------------------------------------------------------------- /FruitMarket/src/img/ic_stopwatch.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahmoudhamwi/Fruits-Market/HEAD/FruitMarket/src/img/ic_stopwatch.png -------------------------------------------------------------------------------- /FruitMarket/out/production/FruitMarket/img/banana.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahmoudhamwi/Fruits-Market/HEAD/FruitMarket/out/production/FruitMarket/img/banana.png -------------------------------------------------------------------------------- /FruitMarket/out/production/FruitMarket/img/cherry.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahmoudhamwi/Fruits-Market/HEAD/FruitMarket/out/production/FruitMarket/img/cherry.png -------------------------------------------------------------------------------- /FruitMarket/out/production/FruitMarket/img/grapes.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahmoudhamwi/Fruits-Market/HEAD/FruitMarket/out/production/FruitMarket/img/grapes.png -------------------------------------------------------------------------------- /FruitMarket/out/production/FruitMarket/img/kiwi.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahmoudhamwi/Fruits-Market/HEAD/FruitMarket/out/production/FruitMarket/img/kiwi.png -------------------------------------------------------------------------------- /FruitMarket/out/production/FruitMarket/img/mango.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahmoudhamwi/Fruits-Market/HEAD/FruitMarket/out/production/FruitMarket/img/mango.png -------------------------------------------------------------------------------- /FruitMarket/out/production/FruitMarket/img/orange.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahmoudhamwi/Fruits-Market/HEAD/FruitMarket/out/production/FruitMarket/img/orange.png -------------------------------------------------------------------------------- /FruitMarket/out/production/FruitMarket/img/peach.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahmoudhamwi/Fruits-Market/HEAD/FruitMarket/out/production/FruitMarket/img/peach.png -------------------------------------------------------------------------------- /FruitMarket/out/production/FruitMarket/img/coconut.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahmoudhamwi/Fruits-Market/HEAD/FruitMarket/out/production/FruitMarket/img/coconut.png -------------------------------------------------------------------------------- /FruitMarket/out/production/FruitMarket/img/ic_cart.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahmoudhamwi/Fruits-Market/HEAD/FruitMarket/out/production/FruitMarket/img/ic_cart.png -------------------------------------------------------------------------------- /FruitMarket/out/production/FruitMarket/main/Main.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahmoudhamwi/Fruits-Market/HEAD/FruitMarket/out/production/FruitMarket/main/Main.class -------------------------------------------------------------------------------- /FruitMarket/out/production/FruitMarket/img/ic_delivery.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahmoudhamwi/Fruits-Market/HEAD/FruitMarket/out/production/FruitMarket/img/ic_delivery.png -------------------------------------------------------------------------------- /FruitMarket/out/production/FruitMarket/img/strawberry.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahmoudhamwi/Fruits-Market/HEAD/FruitMarket/out/production/FruitMarket/img/strawberry.png -------------------------------------------------------------------------------- /FruitMarket/out/production/FruitMarket/img/watermelon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahmoudhamwi/Fruits-Market/HEAD/FruitMarket/out/production/FruitMarket/img/watermelon.png -------------------------------------------------------------------------------- /FruitMarket/out/production/FruitMarket/model/Fruit.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahmoudhamwi/Fruits-Market/HEAD/FruitMarket/out/production/FruitMarket/model/Fruit.class -------------------------------------------------------------------------------- /FruitMarket/out/production/FruitMarket/img/ic_stopwatch.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahmoudhamwi/Fruits-Market/HEAD/FruitMarket/out/production/FruitMarket/img/ic_stopwatch.png -------------------------------------------------------------------------------- /FruitMarket/out/production/FruitMarket/main/MyListener.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahmoudhamwi/Fruits-Market/HEAD/FruitMarket/out/production/FruitMarket/main/MyListener.class -------------------------------------------------------------------------------- /FruitMarket/src/main/MyListener.java: -------------------------------------------------------------------------------- 1 | package main; 2 | 3 | import model.Fruit; 4 | 5 | public interface MyListener { 6 | public void onClickListener(Fruit fruit); 7 | } 8 | -------------------------------------------------------------------------------- /FruitMarket/out/production/FruitMarket/Controller/ItemController.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahmoudhamwi/Fruits-Market/HEAD/FruitMarket/out/production/FruitMarket/Controller/ItemController.class -------------------------------------------------------------------------------- /FruitMarket/out/production/FruitMarket/Controller/MarketController.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahmoudhamwi/Fruits-Market/HEAD/FruitMarket/out/production/FruitMarket/Controller/MarketController.class -------------------------------------------------------------------------------- /FruitMarket/out/production/FruitMarket/Controller/MarketController$1.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mahmoudhamwi/Fruits-Market/HEAD/FruitMarket/out/production/FruitMarket/Controller/MarketController$1.class -------------------------------------------------------------------------------- /FruitMarket/FruitMarket.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Fruits-Market 2 | # Tutorial 3 | Watch Fruits Market Tutorial step by step on youtube: 4 | [https://youtu.be/0IDuEPCo1oY](https://youtu.be/XlAzQ170kzM?si=KKIxNocn-lWatsI-) 5 | 6 | # Screenshot 7 | ![alt text](https://raw.githubusercontent.com/mahmoudhamwi/Fruits-Market/master/FruitMarket/Screenshot/image1.png) 8 | ![alt text](https://raw.githubusercontent.com/mahmoudhamwi/Fruits-Market/master/FruitMarket/Screenshot/image2.PNG) 9 | ![alt text](https://raw.githubusercontent.com/mahmoudhamwi/Fruits-Market/master/FruitMarket/Screenshot/image3.PNG) 10 | ![alt text](https://raw.githubusercontent.com/mahmoudhamwi/Fruits-Market/master/FruitMarket/Screenshot/image4.PNG) 11 | -------------------------------------------------------------------------------- /FruitMarket/src/main/Main.java: -------------------------------------------------------------------------------- 1 | package main; 2 | 3 | import javafx.application.Application; 4 | import javafx.fxml.FXMLLoader; 5 | import javafx.scene.Parent; 6 | import javafx.scene.Scene; 7 | import javafx.stage.Stage; 8 | 9 | public class Main extends Application { 10 | 11 | public static final String CURRENCY = "$"; 12 | @Override 13 | public void start(Stage primaryStage) throws Exception{ 14 | Parent root = FXMLLoader.load(getClass().getResource("../views/market.fxml")); 15 | primaryStage.setTitle("Fruits Marker"); 16 | primaryStage.setScene(new Scene(root)); 17 | primaryStage.show(); 18 | } 19 | 20 | 21 | public static void main(String[] args) { 22 | launch(args); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /FruitMarket/src/model/Fruit.java: -------------------------------------------------------------------------------- 1 | package model; 2 | 3 | public class Fruit { 4 | private String name; 5 | private String imgSrc; 6 | private double price; 7 | private String color; 8 | 9 | public String getName() { 10 | return name; 11 | } 12 | 13 | public void setName(String name) { 14 | this.name = name; 15 | } 16 | 17 | public String getImgSrc() { 18 | return imgSrc; 19 | } 20 | 21 | public void setImgSrc(String imgSrc) { 22 | this.imgSrc = imgSrc; 23 | } 24 | 25 | public double getPrice() { 26 | return price; 27 | } 28 | 29 | public void setPrice(double price) { 30 | this.price = price; 31 | } 32 | 33 | public String getColor() { 34 | return color; 35 | } 36 | 37 | public void setColor(String color) { 38 | this.color = color; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /FruitMarket/src/values/style.css: -------------------------------------------------------------------------------- 1 | .search-box{ 2 | -fx-background-color:#FFFFFF; 3 | -fx-background-radius: 100; 4 | } 5 | 6 | .transparent{ 7 | -fx-background-color: rgba(0,0,0,0); 8 | } 9 | 10 | .search-button{ 11 | -fx-background-color: #828282; 12 | -fx-background-radius: 30; 13 | } 14 | 15 | .right-bar{ 16 | -fx-background-color: #D3D3D3; 17 | } 18 | 19 | .shadow{ 20 | -fx-effect: dropShadow(three-pass-box,rgba(0,0,0,0.1), 10.0 , 0.0 , 0.0 ,10.0); 21 | } 22 | 23 | .chosen-fruit-card{ 24 | -fx-background-color: #F16C31; 25 | -fx-background-radius: 30; 26 | } 27 | 28 | .comboBox{ 29 | -fx-background-color: rgba(255,255,255,0.3); 30 | -fx-background-radius: 30; 31 | } 32 | 33 | .add-btn{ 34 | -fx-background-color: #FFFFFF; 35 | -fx-background-radius: 100; 36 | } 37 | 38 | .free-delivery-card{ 39 | -fx-background-color: #D3D3D3; 40 | -fx-background-radius: 30; 41 | } 42 | 43 | .shopping-online-card{ 44 | -fx-background-color: #BAEAC3; 45 | -fx-background-radius: 30; 46 | } 47 | 48 | .fruit-item{ 49 | -fx-background-color: #FFFFFF; 50 | -fx-background-radius: 30; 51 | } -------------------------------------------------------------------------------- /FruitMarket/src/Controller/ItemController.java: -------------------------------------------------------------------------------- 1 | package Controller; 2 | 3 | import javafx.event.ActionEvent; 4 | import javafx.fxml.FXML; 5 | import javafx.scene.control.Label; 6 | import javafx.scene.image.Image; 7 | import javafx.scene.image.ImageView; 8 | import javafx.scene.input.MouseEvent; 9 | import main.Main; 10 | import main.MyListener; 11 | import model.Fruit; 12 | 13 | public class ItemController { 14 | @FXML 15 | private Label nameLabel; 16 | 17 | @FXML 18 | private Label priceLable; 19 | 20 | @FXML 21 | private ImageView img; 22 | 23 | @FXML 24 | private void click(MouseEvent mouseEvent) { 25 | myListener.onClickListener(fruit); 26 | } 27 | 28 | private Fruit fruit; 29 | private MyListener myListener; 30 | 31 | public void setData(Fruit fruit, MyListener myListener) { 32 | this.fruit = fruit; 33 | this.myListener = myListener; 34 | nameLabel.setText(fruit.getName()); 35 | priceLable.setText(Main.CURRENCY + fruit.getPrice()); 36 | Image image = new Image(getClass().getResourceAsStream(fruit.getImgSrc())); 37 | img.setImage(image); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /FruitMarket/out/production/FruitMarket/values/style.css: -------------------------------------------------------------------------------- 1 | .search-box{ 2 | -fx-background-color:#FFFFFF; 3 | -fx-background-radius: 100; 4 | } 5 | 6 | .transparent{ 7 | -fx-background-color: rgba(0,0,0,0); 8 | } 9 | 10 | .search-button{ 11 | -fx-background-color: #828282; 12 | -fx-background-radius: 30; 13 | } 14 | 15 | .right-bar{ 16 | -fx-background-color: #D3D3D3; 17 | } 18 | 19 | .shadow{ 20 | -fx-effect: dropShadow(three-pass-box,rgba(0,0,0,0.1), 10.0 , 0.0 , 0.0 ,10.0); 21 | } 22 | 23 | .chosen-fruit-card{ 24 | -fx-background-color: #F16C31; 25 | -fx-background-radius: 30; 26 | } 27 | 28 | .comboBox{ 29 | -fx-background-color: rgba(255,255,255,0.3); 30 | -fx-background-radius: 30; 31 | } 32 | 33 | .add-btn{ 34 | -fx-background-color: #FFFFFF; 35 | -fx-background-radius: 100; 36 | } 37 | 38 | .free-delivery-card{ 39 | -fx-background-color: #D3D3D3; 40 | -fx-background-radius: 30; 41 | } 42 | 43 | .shopping-online-card{ 44 | -fx-background-color: #BAEAC3; 45 | -fx-background-radius: 30; 46 | } 47 | 48 | .fruit-item{ 49 | -fx-background-color: #FFFFFF; 50 | -fx-background-radius: 30; 51 | } -------------------------------------------------------------------------------- /FruitMarket/src/views/item.fxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 25 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /FruitMarket/out/production/FruitMarket/views/item.fxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 25 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /FruitMarket/src/Controller/MarketController.java: -------------------------------------------------------------------------------- 1 | package Controller; 2 | 3 | import javafx.fxml.FXML; 4 | import javafx.fxml.FXMLLoader; 5 | import javafx.fxml.Initializable; 6 | import javafx.geometry.Insets; 7 | import javafx.scene.control.Label; 8 | import javafx.scene.control.ScrollPane; 9 | import javafx.scene.image.Image; 10 | import javafx.scene.image.ImageView; 11 | import javafx.scene.layout.AnchorPane; 12 | import javafx.scene.layout.GridPane; 13 | import javafx.scene.layout.Region; 14 | import javafx.scene.layout.VBox; 15 | import main.Main; 16 | import main.MyListener; 17 | import model.Fruit; 18 | 19 | import java.io.IOException; 20 | import java.net.URL; 21 | import java.util.ArrayList; 22 | import java.util.List; 23 | import java.util.ResourceBundle; 24 | 25 | public class MarketController implements Initializable { 26 | @FXML 27 | private VBox chosenFruitCard; 28 | 29 | @FXML 30 | private Label fruitNameLable; 31 | 32 | @FXML 33 | private Label fruitPriceLabel; 34 | 35 | @FXML 36 | private ImageView fruitImg; 37 | 38 | @FXML 39 | private ScrollPane scroll; 40 | 41 | @FXML 42 | private GridPane grid; 43 | 44 | private List fruits = new ArrayList<>(); 45 | private Image image; 46 | private MyListener myListener; 47 | 48 | private List getData() { 49 | List fruits = new ArrayList<>(); 50 | Fruit fruit; 51 | 52 | fruit = new Fruit(); 53 | fruit.setName("Kiwi"); 54 | fruit.setPrice(2.99); 55 | fruit.setImgSrc("/img/kiwi.png"); 56 | fruit.setColor("6A7324"); 57 | fruits.add(fruit); 58 | 59 | fruit = new Fruit(); 60 | fruit.setName("Coconut"); 61 | fruit.setPrice(3.99); 62 | fruit.setImgSrc("/img/coconut.png"); 63 | fruit.setColor("A7745B"); 64 | fruits.add(fruit); 65 | 66 | fruit = new Fruit(); 67 | fruit.setName("Peach"); 68 | fruit.setPrice(1.50); 69 | fruit.setImgSrc("/img/peach.png"); 70 | fruit.setColor("F16C31"); 71 | fruits.add(fruit); 72 | 73 | fruit = new Fruit(); 74 | fruit.setName("Grapes"); 75 | fruit.setPrice(0.99); 76 | fruit.setImgSrc("/img/grapes.png"); 77 | fruit.setColor("291D36"); 78 | fruits.add(fruit); 79 | 80 | fruit = new Fruit(); 81 | fruit.setName("Watermelon"); 82 | fruit.setPrice(4.99); 83 | fruit.setImgSrc("/img/watermelon.png"); 84 | fruit.setColor("22371D"); 85 | fruits.add(fruit); 86 | 87 | fruit = new Fruit(); 88 | fruit.setName("Orange"); 89 | fruit.setPrice(2.99); 90 | fruit.setImgSrc("/img/orange.png"); 91 | fruit.setColor("FB5D03"); 92 | fruits.add(fruit); 93 | 94 | fruit = new Fruit(); 95 | fruit.setName("StrawBerry"); 96 | fruit.setPrice(0.99); 97 | fruit.setImgSrc("/img/strawberry.png"); 98 | fruit.setColor("80080C"); 99 | fruits.add(fruit); 100 | 101 | fruit = new Fruit(); 102 | fruit.setName("Mango"); 103 | fruit.setPrice(0.99); 104 | fruit.setImgSrc("/img/mango.png"); 105 | fruit.setColor("FFB605"); 106 | fruits.add(fruit); 107 | 108 | fruit = new Fruit(); 109 | fruit.setName("Cherry"); 110 | fruit.setPrice(0.99); 111 | fruit.setImgSrc("/img/cherry.png"); 112 | fruit.setColor("5F060E"); 113 | fruits.add(fruit); 114 | 115 | fruit = new Fruit(); 116 | fruit.setName("Banana"); 117 | fruit.setPrice(1.99); 118 | fruit.setImgSrc("/img/banana.png"); 119 | fruit.setColor("E7C00F"); 120 | fruits.add(fruit); 121 | 122 | return fruits; 123 | } 124 | 125 | private void setChosenFruit(Fruit fruit) { 126 | fruitNameLable.setText(fruit.getName()); 127 | fruitPriceLabel.setText(Main.CURRENCY + fruit.getPrice()); 128 | image = new Image(getClass().getResourceAsStream(fruit.getImgSrc())); 129 | fruitImg.setImage(image); 130 | chosenFruitCard.setStyle("-fx-background-color: #" + fruit.getColor() + ";\n" + 131 | " -fx-background-radius: 30;"); 132 | } 133 | 134 | @Override 135 | public void initialize(URL location, ResourceBundle resources) { 136 | fruits.addAll(getData()); 137 | if (fruits.size() > 0) { 138 | setChosenFruit(fruits.get(0)); 139 | myListener = new MyListener() { 140 | @Override 141 | public void onClickListener(Fruit fruit) { 142 | setChosenFruit(fruit); 143 | } 144 | }; 145 | } 146 | int column = 0; 147 | int row = 1; 148 | try { 149 | for (int i = 0; i < fruits.size(); i++) { 150 | FXMLLoader fxmlLoader = new FXMLLoader(); 151 | fxmlLoader.setLocation(getClass().getResource("/views/item.fxml")); 152 | AnchorPane anchorPane = fxmlLoader.load(); 153 | 154 | ItemController itemController = fxmlLoader.getController(); 155 | itemController.setData(fruits.get(i),myListener); 156 | 157 | if (column == 3) { 158 | column = 0; 159 | row++; 160 | } 161 | 162 | grid.add(anchorPane, column++, row); //(child,column,row) 163 | //set grid width 164 | grid.setMinWidth(Region.USE_COMPUTED_SIZE); 165 | grid.setPrefWidth(Region.USE_COMPUTED_SIZE); 166 | grid.setMaxWidth(Region.USE_PREF_SIZE); 167 | 168 | //set grid height 169 | grid.setMinHeight(Region.USE_COMPUTED_SIZE); 170 | grid.setPrefHeight(Region.USE_COMPUTED_SIZE); 171 | grid.setMaxHeight(Region.USE_PREF_SIZE); 172 | 173 | GridPane.setMargin(anchorPane, new Insets(10)); 174 | } 175 | } catch (IOException e) { 176 | e.printStackTrace(); 177 | } 178 | } 179 | 180 | } 181 | -------------------------------------------------------------------------------- /FruitMarket/src/views/market.fxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 36 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 |
150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 162 | 167 | 168 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 192 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 216 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 |
255 | 256 | 257 |
258 | -------------------------------------------------------------------------------- /FruitMarket/out/production/FruitMarket/views/market.fxml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 36 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 |
150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 162 | 167 | 168 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 192 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 216 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 |
255 | 256 | 257 |
258 | --------------------------------------------------------------------------------