Skip to content

Commit

Permalink
Merge pull request #47 from solvena/44-stock-tab-on-ui-doesnt-automat…
Browse files Browse the repository at this point in the history
…ically-update

44 stock tab on UI now automatically updates
  • Loading branch information
solvena authored May 26, 2026
2 parents b027d86 + 137981a commit d7ae460
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 d7ae460

Please sign in to comment.