Skip to content
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
23 changes: 15 additions & 8 deletions src/main/java/net/imagej/legacy/IJ1Helper.java
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ public class IJ1Helper extends AbstractContextual {

/** Task bar in the main window. */
private Object taskBar;
private TaskMonitorButtonHacker taskMonitorHacker;

/** Whether we are in the process of forcibly shutting down ImageJ1. */
private boolean disposing;
Expand All @@ -155,14 +156,8 @@ public void initialize() {
log.error(t);
}

// add the task monitor icon
try {
taskBar = new TaskMonitorButtonHacker(getContext()).addTaskBar(ij1);
}
catch (final Throwable t) {
// NB: Do not let this crash ImageJ on startup!
log.error(t);
}
// NB: Task monitor icon is added later in setVisible(),
// after the Look and Feel has been initialized.

if (getCommands() == null) {
IJ.runPlugIn("ij.IJ.init", "");
Expand Down Expand Up @@ -324,6 +319,18 @@ public void setVisible(final boolean toggle) {
legacyService.context().getService(SwingLookAndFeelService.class);
if (lafService != null) lafService.initLookAndFeel();

// Add the task monitor icon after the LaF is initialized,
// so that all components are created with the correct theme.
if (taskBar == null) {
try {
taskMonitorHacker = new TaskMonitorButtonHacker(getContext());
taskBar = taskMonitorHacker.addTaskBar(ij);
}
catch (final Throwable t) {
log.error(t);
}
}

ij.pack();
}
ij.setVisible(toggle);
Expand Down
Loading