parent Window To Front - Java java.awt

Java examples for java.awt:Window

Description

parent Window To Front

Demo Code


//package com.java2s;
import java.awt.Component;
import java.awt.Container;

import java.awt.Window;

public class Main {
    public static void parentWindowToFront(Component component) {
        if (component == null) {
            throw new NullPointerException("component == null");
        }// w w w  .ja v a  2  s.c o m
        Container parent = component.getParent();
        while (parent != null) {
            if ((parent instanceof Window)) {
                Window parentWindow = (Window) parent;
                parentWindow.toFront();
                return;
            }
            parent = parent.getParent();
        }
    }
}

Related Tutorials