diff --git a/MekHQ/src/mekhq/gui/dialog/ManageAssetsDialog.java b/MekHQ/src/mekhq/gui/dialog/ManageAssetsDialog.java index f82dff1ccb..4f19eb804e 100644 --- a/MekHQ/src/mekhq/gui/dialog/ManageAssetsDialog.java +++ b/MekHQ/src/mekhq/gui/dialog/ManageAssetsDialog.java @@ -163,14 +163,15 @@ private void editAsset() { } private void deleteAsset() { - campaign.getFinances().getAssets().remove(assetTable.getSelectedRow()); MekHQ.triggerEvent(new AssetRemovedEvent(assetModel.getAssetAt(assetTable.getSelectedRow()))); + campaign.getFinances().getAssets().remove(assetTable.getSelectedRow()); refreshTable(); } private void refreshTable() { int selectedRow = assetTable.getSelectedRow(); assetModel.setData(campaign.getFinances().getAssets()); + if (selectedRow != -1) { if (assetTable.getRowCount() > 0) { if (assetTable.getRowCount() == selectedRow) { @@ -208,18 +209,13 @@ public int getColumnCount() { @Override public String getColumnName(int column) { - switch (column) { - case COL_NAME: - return "Name"; - case COL_VALUE: - return "Value"; - case COL_SCHEDULE: - return "Pay Frequency"; - case COL_INCOME: - return "Income"; - default: - return "?"; - } + return switch (column) { + case COL_NAME -> "Name"; + case COL_VALUE -> "Value"; + case COL_SCHEDULE -> "Pay Frequency"; + case COL_INCOME -> "Income"; + default -> "?"; + }; } @Override @@ -255,30 +251,22 @@ public Asset getAssetAt(int row) { } public int getColumnWidth(int c) { - switch (c) { - default: - return 10; - } + return 10; } public int getAlignment(int col) { - switch (col) { - case COL_NAME: - return SwingConstants.LEFT; - default: - return SwingConstants.RIGHT; + if (col == COL_NAME) { + return SwingConstants.LEFT; } + return SwingConstants.RIGHT; } public String getTooltip(int row, int col) { - switch (col) { - default: - return null; - } + return null; } - public AssetTableModel.Renderer getRenderer() { - return new AssetTableModel.Renderer(); + public Renderer getRenderer() { + return new Renderer(); } public class Renderer extends DefaultTableCellRenderer {