Skip to content

Commit

Permalink
Stock tab in UI now updates automatically
Browse files Browse the repository at this point in the history
  • Loading branch information
elisab3 committed May 26, 2026
1 parent ead1d98 commit 137981a
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/main/java/View/MainGameScene.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,11 @@ public class MainGameScene implements ExchangeObserver {

// References to UI components that need refreshing
private TableView<PortfolioRow> portfolioTable;
private TableView<StockRow> table;
private ListView<Share> holdingsList;
private TableView<HistoryRow> historyTable;
private ComboBox<Integer> weekFilterCombo;
private Runnable loadStocks;

/**
* Constructs the main game scene.
Expand Down Expand Up @@ -159,10 +161,10 @@ private VBox createStocksPanel() {
filter.setItems(FXCollections.observableArrayList("All", "Gainers", "Losers"));
filter.setValue("All");

TableView<StockRow> table = new TableView<>();
table = new TableView<>();
addStockColumns(table);

Runnable loadStocks = () -> {
loadStocks = () -> {
List<Stock> stocks;
String filterVal = filter.getValue();
String searchVal = search.getText().trim();
Expand Down Expand Up @@ -575,6 +577,9 @@ private void updateStatus() {
}

private void refreshAllUI() {
if (table != null && loadStocks != null) {
loadStocks.run();
}
if (portfolioTable != null) {
updatePortfolio(portfolioTable);
}
Expand Down

0 comments on commit 137981a

Please sign in to comment.