-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVitrineApp.java
More file actions
97 lines (84 loc) · 3.21 KB
/
Copy pathVitrineApp.java
File metadata and controls
97 lines (84 loc) · 3.21 KB
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
package View;
import Controler.Carrinho;
import Model.Produto;
import javafx.application.Application;
import javafx.beans.property.SimpleDoubleProperty;
import javafx.beans.property.SimpleStringProperty;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.PasswordField;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.control.TextField;
import javafx.scene.control.cell.PropertyValueFactory;
import javafx.scene.layout.AnchorPane;
import javafx.stage.Stage;
public class VitrineApp extends Application {
private AnchorPane pane;
private TextField txPesquisa;
private TableView<ItensProperty> tbVitrine;
private TableColumn<ItensProperty, String> columnProduto;
private TableColumn<ItensProperty, Double> columnPreco;
private static ObservableList<ItensProperty> listItens = FXCollections.observableArrayList();
private static Carrinho carrinho;
private static Stage stage;
@Override
public void start(Stage arg0) throws Exception {
initComponents();
Scene scene = new Scene(pane); //INSTANCIA A SENA
arg0.setScene(scene); // SETA SENA NO PALCO
arg0.setResizable(false); //REMOVE A OP DE MAX A TELA
arg0.setTitle("Login - GolFX"); //TITULO
arg0.show(); // MOSTRA O PALCO
VitrineApp.stage = arg0;
}
public static void main(String[] args) {
launch(args);
}
private void initComponents() {
pane = new AnchorPane(); //Painel
pane.setPrefSize(800, 600);
txPesquisa = new TextField(); //texto pesquisa
txPesquisa.setPromptText("Digite o item para pesquisa");
tbVitrine = new TableView<ItensProperty>();
tbVitrine.setPrefSize(780, 550);
columnProduto = new TableColumn<ItensProperty, String>();
columnPreco = new TableColumn<ItensProperty, Double>();
tbVitrine.getColumns().addAll(columnProduto, columnPreco);
pane.getChildren().addAll(txPesquisa, tbVitrine);
carrinho = new Carrinho();
columnProduto.setCellValueFactory(new PropertyValueFactory<ItensProperty, String>("produto"));
columnPreco.setCellValueFactory(new PropertyValueFactory<ItensProperty, Double>("preco"));
tbVitrine.setItems(listItens);
}
private void initItens(){
Vitrine v = new Vitrine();
v.addProdutos(new Produto("Bola Topper", 15.00), new Produto(
"Luvas Umbro", 9.00), new Produto("Camisa Esportiva", 40.00),
new Produto("Chuteira Nike Mercurial", 199.00), new Produto("Caneleira Topper", 10.00));
for (Produto p : v.getProdutos())
listItens.add(new ItensProperty(p.getProduto(), p.getPreco()));
}
public class ItensProperty {
private SimpleStringProperty produto;
private SimpleDoubleProperty preco;
public ItensProperty(String produto, double preco) {
this.produto = new SimpleStringProperty(produto);
this.preco = new SimpleDoubleProperty(preco);
}
public String getProduto() {
return produto.get();
}
public void setProduto(String produto) {
this.produto.set(produto);
}
public double getPreco() {
return preco.get();
}
public void setPreco(double preco) {
this.preco.set(preco);
}
}
}