Here you can find the source of getRootFrame(Component c)
Parameter | Description |
---|---|
c | a parameter |
public static Frame getRootFrame(Component c)
//package com.java2s; /*//from w w w . ja v a2 s .c om * * This file is part of Genome Artist. * * Genome Artist is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Genome Artist is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Genome Artist. If not, see <http://www.gnu.org/licenses/>. * */ import java.awt.Component; import java.awt.Dialog; import java.awt.Frame; import java.awt.Window; import javax.swing.SwingUtilities; public class Main { private static Frame PHONY_FRAME = null; /** * Get the root frame of any component * @param c * @return the top level frame sau un frame phony */ public static Frame getRootFrame(Component c) { if (c != null) { Window window = SwingUtilities.getWindowAncestor(c); if (window instanceof Frame) { return (Frame) window; } else if (window instanceof Dialog) { Dialog dialog = (Dialog) window; return getRootFrame(dialog.getOwner()); } } //Valoare default return getPhonyFrame(); } /** * Initialize un phony frame lazy * @return */ private static Frame getPhonyFrame() { if (PHONY_FRAME == null) { PHONY_FRAME = new Frame("phony"); } //Phony frame return PHONY_FRAME; } }