206
207 String notificationText = invasion.getDistrict() + " - " + invasion.getCogType().replace("\u0003", "");
208 Notify notify = Notify.Companion.create().title(messageTitle).text(notificationText).theme(Theme.Companion.getDefaultDark()).position(Position.BOTTOM_RIGHT).hideAfter(5000).image(CustomLauncherRewrite.icon);
209 notify.show();210 }
211
212 /**
196
197 String notificationText = zonesToStreets.get(fieldOffice.getArea()) + " - " + fieldOffice.getDifficulty() + " star(s)";
198 Notify notify = Notify.Companion.create().title(messageTitle).text(notificationText).theme(Theme.Companion.getDefaultDark()).position(Position.BOTTOM_RIGHT).hideAfter(5000).image(CustomLauncherRewrite.icon);
199 notify.show();200 }
201
202 /**
113
114 // run the TTR updater
115 TTRUpdater ttrUpdater = new TTRUpdater();
116 ttrUpdater.setVisible(true);117 ttrUpdater.checkUpdates(manifest);
118
119 logger.info("Launching game from " + installPath.getAbsolutePath());
214
215 logger.info("Downloading " + PATCHES_URL_DL + downloadName);
216 updateStatus.setText("Downloading " + downloadName);
217 progressBar.setVisible(true);218 progressBar.setValue(progressBar.getValue() + 1);
219
220 // build the download URL
Methods show()
, setVisible()
, and pack()
must not be invoked on the main thread.
With each invocation, these methods create the peer for the associated JFrame
. Creation of the peer involves creation of the event dispatch thread.
At this point, the event dispatch thread could be in the middle of notifying listeners while show()
, setVisible()
, or pack()
is still executing.
As a result, we could have two threads going through the Swing component-based GUI at the same time, which is a serious issue that might lead to deadlocks or other multithreading bugs.
public void method() {
// These are problematic.
frame.show();
frame.setVisible(true);
frame.pack();
}
Consider calling these methods on the event dispatch thread.
public void method() {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
frame.show();
frame.setVisible(true);
frame.pack();
}
}
}