hiscore: modify the ui on the edt only

This commit is contained in:
Max Weber
2020-05-15 02:06:09 -06:00
committed by Adam
parent 6a2e15643f
commit cb0d9ce3d0
2 changed files with 5 additions and 17 deletions

View File

@@ -194,7 +194,7 @@ public class HiscorePanel extends PluginPanel
if (localPlayer != null) if (localPlayer != null)
{ {
executor.execute(() -> lookup(localPlayer.getName())); lookup(localPlayer.getName());
} }
} }
}); });
@@ -363,7 +363,7 @@ public class HiscorePanel extends PluginPanel
{ {
searchBar.setText(username); searchBar.setText(username);
resetEndpoints(); resetEndpoints();
lookup(); executor.execute(this::lookup);
} }
private void lookup() private void lookup()

View File

@@ -28,7 +28,6 @@ import com.google.common.collect.ImmutableList;
import com.google.common.collect.ObjectArrays; import com.google.common.collect.ObjectArrays;
import com.google.inject.Provides; import com.google.inject.Provides;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import java.lang.reflect.InvocationTargetException;
import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ScheduledExecutorService;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
@@ -213,23 +212,12 @@ public class HiscorePlugin extends Plugin
private void lookupPlayer(String playerName) private void lookupPlayer(String playerName)
{ {
executor.execute(() -> SwingUtilities.invokeLater(() ->
{ {
try if (!navButton.isSelected())
{ {
SwingUtilities.invokeAndWait(() -> navButton.getOnSelect().run();
{
if (!navButton.isSelected())
{
navButton.getOnSelect().run();
}
});
} }
catch (InterruptedException | InvocationTargetException e)
{
throw new RuntimeException(e);
}
hiscorePanel.lookup(playerName); hiscorePanel.lookup(playerName);
}); });
} }