-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathJava2
More file actions
71 lines (52 loc) · 2.18 KB
/
Java2
File metadata and controls
71 lines (52 loc) · 2.18 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
package javafxapplication1;
import javafx.application.Application;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.scene.Scene;
import javafx.scene.control.TableView;
import javafx.scene.control.TableColumn;
import javafx.scene.control.cell.PropertyValueFactory;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
public class JavaFXApplication1 extends Application{
public Stage MainStage;
public Scene InventoryScene;
public TableView<Entry> EntryTable;
public PropertyValueFactory<Entry, String> nameFactory;
public PropertyValueFactory<Entry, Integer> quantityFactory;
public ObservableList<Entry> CurrentInventory;
public static void main(String[] args) {
launch(args);
}
@Override
public void start(Stage MainStage) throws Exception {
MainStage.setTitle("Inventory Manager");
TableColumn<Entry, String> nameColumn;
TableColumn<Entry, Integer> quantityColumn;
TableColumn<Entry, String> notesColumn;
nameColumn = new TableColumn<>("Name");
nameColumn.setMinWidth(200);
nameColumn.setCellValueFactory(new PropertyValueFactory<> ("name"));
quantityColumn = new TableColumn<>("Quantity");
quantityColumn.setMinWidth(200);
quantityColumn.setCellValueFactory(new PropertyValueFactory<> ("quantity"));
notesColumn = new TableColumn<>("Description");
notesColumn.setMinWidth(200);
notesColumn.setCellValueFactory(new PropertyValueFactory<> ("notes"));
EntryTable = new TableView<>();
EntryTable.setItems( getEntry() );
EntryTable.getColumns().addAll(nameColumn, quantityColumn, notesColumn);
VBox stockBox;
stockBox = new VBox();
stockBox.getChildren().addAll(EntryTable);
InventoryScene = new Scene(stockBox);
MainStage.setScene(InventoryScene);
MainStage.show();
}
public ObservableList<Entry> getEntry(){
CurrentInventory = FXCollections.observableArrayList();
CurrentInventory.add(new Entry ("Bananas", 12, "Not Ripe!"));
CurrentInventory.add(new Entry ("Yikes", 1000000, "Lmao"));
return CurrentInventory;
}
}