Java JFrame toFrontHack(JFrame theParent, JFrame theFrame)

Here you can find the source of toFrontHack(JFrame theParent, JFrame theFrame)

Description

Moves a frame in front of another frame

License

Open Source License

Parameter

Parameter Description
theParent JFrame the parent, or reference frame
theFrame JFrame the frame to move in front

Declaration

public static void toFrontHack(JFrame theParent, JFrame theFrame) 

Method Source Code

//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();
    }
}

Related

  1. storePrefsFrame(Preferences node, JFrame frame)
  2. tellUserToChoose(JFrame jFrame)
  3. terminarPrograma(JFrame f)
  4. toFront(final JFrame window)
  5. toFront(JFrame frame)
  6. toggleFrame(JFrame frame)
  7. toggleOsXFullScreen(JFrame frame)
  8. unpackArchive(URL url, File targetDir, JFrame frame, ProgressMonitor progressMonitor)
  9. waitFor(JFrame popup)