Example usage for java.awt Container isShowing

List of usage examples for java.awt Container isShowing

Introduction

In this page you can find the example usage for java.awt Container isShowing.

Prototype

public boolean isShowing() 

Source Link

Document

Determines whether this component is showing on screen.

Usage

From source file:Main.java

public static void centerInOwner(Dialog dialog) {
    Container parent = dialog.getOwner();
    if (parent != null && parent.isShowing())
        centerInParent(dialog, dialog.getParent());
    else// w w w  .  j a v  a2 s  .  co m
        center(dialog);
}

From source file:Main.java

public static Point getRelLocation(Component c) {
    if (c == null || !c.isShowing()) {
        return new Point(0, 0);
    }/*from ww  w  .  java 2 s  . co m*/

    Container parent = getRootContainer(c);
    if ((parent != null) && parent.isShowing()) {
        Point p1 = c.getLocationOnScreen();
        Point p2 = parent.getLocationOnScreen();
        return new Point(p1.x - p2.x, p1.y - p2.y);
    }

    return new Point(0, 0);
}

From source file:org.esa.nest.dat.views.polarview.PolarCanvas.java

private static void paintComponents(Container c, Graphics g) {
    if (!c.isShowing())
        return;/* ww w. j ava2 s.  c o  m*/

    final int ncomponents = c.getComponentCount();
    final Rectangle clip = g.getClipBounds();

    int i = ncomponents - 1;
    while (i >= 0) {
        final Component component[] = c.getComponents();
        final Component comp = component[i];
        if (comp == null || !comp.isVisible())
            continue;
        final Rectangle bounds = comp.getBounds();
        Rectangle cr;
        if (clip == null)
            cr = new Rectangle(bounds);
        else
            cr = bounds.intersection(clip);
        if (cr.isEmpty())
            continue;

        final Graphics cg = g.create();
        cg.setClip(cr);
        cg.translate(bounds.x, bounds.y);
        try {
            comp.paint(cg);
        } catch (Throwable e) {
            //
        }

        cg.dispose();
        i--;
    }
}