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

Added Exception Handling for Out-of_Bounds Tab Index Selection #5788

Merged
merged 3 commits into from
Jan 15, 2025
Merged
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
8 changes: 6 additions & 2 deletions MekHQ/src/mekhq/gui/TOETab.java
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,12 @@ public Dimension getPreferredScrollableViewportSize() {
tabUnit.add("Unit", scrollUnit);
panForceView.add(tabUnit, BorderLayout.CENTER);
SwingUtilities.invokeLater(() -> scrollUnit.getVerticalScrollBar().setValue(0));
tabUnit.setSelectedIndex(tabUnitLastSelectedIndex);
tabUnit.addChangeListener(evt -> forceViewTabChange()); // added late so it won't overwrite
try {
tabUnit.setSelectedIndex(tabUnitLastSelectedIndex);
tabUnit.addChangeListener(evt -> forceViewTabChange()); // added late so it won't overwrite
} catch (ArrayIndexOutOfBoundsException ignored) {}
// We can ignore here because if the selected index is out of bounds, we're just going
// to not select the unit in the TO&E.
} else if (node instanceof Force) {
final JScrollPane scrollForce = new JScrollPaneWithSpeed(new ForceViewPanel((Force) node, getCampaign()));
panForceView.add(scrollForce, BorderLayout.CENTER);
Expand Down
Loading