mirror of
https://github.com/TotalFreedomMC/ZeroTelnetClient.git
synced 2024-12-22 16:25:14 +00:00
Made player list preserve selection after update.
This commit is contained in:
parent
7569cbfaf2
commit
ea2c171744
1 changed files with 18 additions and 0 deletions
|
@ -28,6 +28,7 @@ import javax.swing.JMenuItem;
|
|||
import javax.swing.JPopupMenu;
|
||||
import javax.swing.JScrollBar;
|
||||
import javax.swing.JTable;
|
||||
import javax.swing.ListSelectionModel;
|
||||
import javax.swing.SwingUtilities;
|
||||
import javax.swing.Timer;
|
||||
import javax.swing.table.DefaultTableModel;
|
||||
|
@ -225,6 +226,8 @@ public class BTC_MainPanel extends javax.swing.JFrame
|
|||
final JTable table = BTC_MainPanel.this.tblPlayers;
|
||||
final DefaultTableModel model = (DefaultTableModel) table.getModel();
|
||||
|
||||
final PlayerInfo player = getSelectedPlayer();
|
||||
|
||||
model.setRowCount(0);
|
||||
|
||||
final Iterator<Map.Entry<String, PlayerInfo>> it = playerList.entrySet().iterator();
|
||||
|
@ -240,6 +243,21 @@ public class BTC_MainPanel extends javax.swing.JFrame
|
|||
playerInfo.getIp()
|
||||
});
|
||||
}
|
||||
|
||||
if (player != null)
|
||||
{
|
||||
final int modelCol = table.convertColumnIndexToModel(0);
|
||||
final int rowCount = table.getRowCount();
|
||||
for (int row = 0; row < rowCount; row++)
|
||||
{
|
||||
if (player.getName().equals(table.getValueAt(row, modelCol).toString()))
|
||||
{
|
||||
final ListSelectionModel selectionModel = table.getSelectionModel();
|
||||
selectionModel.setSelectionInterval(0, row);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue