get Ancestor JDialog from Component - Java Swing

Java examples for Swing:JComponent

Description

get Ancestor JDialog from Component

Demo Code


//package com.java2s;

import java.awt.Component;

import javax.swing.JDialog;

import javax.swing.SwingUtilities;

public class Main {
    public static JDialog getDialog(Component component) {
        if (component instanceof JDialog)
            return (JDialog) component;
        return (JDialog) SwingUtilities.getAncestorOfClass(JDialog.class,
                component);// w  w  w . j  a va  2s.  c  o  m
    }
}

Related Tutorials