Here you can find the source of toFrontHack(JFrame theParent, JFrame theFrame)
Parameter | Description |
---|---|
theParent | JFrame the parent, or reference frame |
theFrame | JFrame the frame to move in front |
public static void toFrontHack(JFrame theParent, JFrame theFrame)
//package com.java2s; // The MIT License import java.awt.Toolkit; import java.awt.Point; import java.awt.Dimension; import java.awt.Frame; import javax.swing.JFrame; public class Main { /**/*from ww w. ja v a 2s . co m*/ * Moves a frame in front of another frame * @param theParent JFrame the parent, or reference frame * @param theFrame JFrame the frame to move in front */ public static void toFrontHack(JFrame theParent, JFrame theFrame) { if (theFrame.getState() == Frame.ICONIFIED) { theFrame.setState(Frame.NORMAL); } else { // save position Point origPos = theFrame.getLocation(); Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); // move off the visible screen theFrame.setLocation(screenSize.width + theParent.getWidth(), screenSize.height + theParent.getHeight()); theFrame.setState(Frame.ICONIFIED); theFrame.setState(Frame.NORMAL); // return to original position theFrame.setLocation(origPos); } // repaint since damage repair is not consistant theParent.repaint(); theFrame.repaint(); } }