Skip to content

Commit

Permalink
Attempt to keep focus
Browse files Browse the repository at this point in the history
  • Loading branch information
CodeByDrescher committed Jan 7, 2025
1 parent 8c361ab commit 9cda231
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
import org.vcell.util.gui.DialogUtils;
import org.vcell.util.gui.GeneralGuiUtils;

import javax.swing.SwingUtilities;
import java.awt.*;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
Expand Down Expand Up @@ -444,6 +445,7 @@ public void run(Hashtable<String, Object> hashTable) throws Exception {
documentWindowManager.addResultsFrame(newWindow);
setFinalWindow(hashTable, viewer);
newWindow.setLocalState(localState);
GeneralGuiUtils.moveToFront(SwingUtilities.getWindowAncestor(viewer));
}
}
}
Expand Down
14 changes: 14 additions & 0 deletions vcell-client/src/main/java/org/vcell/util/gui/GeneralGuiUtils.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package org.vcell.util.gui;

import cbit.vcell.client.task.AsynchClientTask;
import cbit.vcell.client.task.ClientTaskDispatcher;
import com.sun.istack.NotNull;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
Expand Down Expand Up @@ -34,6 +36,7 @@
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Hashtable;


public class GeneralGuiUtils {
Expand Down Expand Up @@ -345,6 +348,17 @@ public static void setCursorThroughout(final Container container, final Cursor c
if(container == null) return;
container.setCursor(cursor);
}

public static void moveToFront(Window targetWindow){
AsynchClientTask task = new AsynchClientTask("Align frame to front", AsynchClientTask.TASKTYPE_SWING_NONBLOCKING) {
@Override
public void run(Hashtable<String, Object> hashTable) {
targetWindow.toFront();
targetWindow.repaint();
}
};
ClientTaskDispatcher.dispatch(targetWindow, new Hashtable<>(), new AsynchClientTask[]{task});
}
}


0 comments on commit 9cda231

Please sign in to comment.