Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

97 close insights window before exit #125

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/main/java/budgetbuddy/BudgetBuddy.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import budgetbuddy.exceptions.InvalidEditTransactionData;
import budgetbuddy.exceptions.InvalidIndexException;
import budgetbuddy.exceptions.InvalidTransactionTypeException;
import budgetbuddy.insights.Insight;
import budgetbuddy.parser.Parser;
import budgetbuddy.storage.DataStorage;
import budgetbuddy.transaction.TransactionList;
Expand Down Expand Up @@ -42,12 +43,13 @@ public void run() {


boolean isRunning = true;

while (isRunning) {
String input = in.nextLine();
try {
switch (input.split(" ")[0]) {
case "bye":
Insight.closeInsightFrames();
UserInterface.printGoodBye();
isRunning = false;
break;
Expand Down
15 changes: 15 additions & 0 deletions src/main/java/budgetbuddy/insights/Insight.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import javax.swing.JPanel;
import java.awt.BorderLayout;
import java.util.ArrayList;
import java.awt.Window;

import static java.lang.Math.abs;

Expand Down Expand Up @@ -102,4 +103,18 @@ private static int indexOf(Category[] array, Category target) {
return -1;
}

//@@author Vavinan
public static void closeInsightFrames() {
// Close any open insight frames here
for (Window window : Window.getWindows()) {
if (window instanceof JFrame) {
String title = ((JFrame) window).getTitle();
if (title != null && (title.equals("Income Insights") || title.equals("Expense Insights"))) {
window.dispose();
}
}
}
}
//@@author

}
Loading