Java JPanel Child unmaskContainer(JPanel pnl)

Here you can find the source of unmaskContainer(JPanel pnl)

Description

unmask Container

License

Apache License

Declaration

public static void unmaskContainer(JPanel pnl) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import javax.swing.*;

import java.awt.*;

public class Main {
    public static void unmaskContainer(JPanel pnl) {
        WindowConstants container = getOutermostContainer(pnl);
        if (container == null) {
            return;
        }//w w  w  .j av a 2 s.  c o  m
        if (container instanceof JDialog) {
            unmaskWindow((JDialog) container);
        } else if (container instanceof JFrame) {
            unmaskWindow((JFrame) container);
        } else if (container instanceof JInternalFrame) {
            unmaskWindow((JInternalFrame) container);
        }
    }

    private static WindowConstants getOutermostContainer(JPanel container) {
        Container pnl = container;
        while (pnl.getParent() != null) {
            if (pnl.getParent() instanceof JInternalFrame) {
                return (JInternalFrame) pnl.getParent();
            }
            if (pnl.getParent() instanceof JDialog) {
                return (JDialog) pnl.getParent();
            }
            if (pnl.getParent() instanceof JFrame) {
                return (JFrame) pnl.getParent();
            }
            pnl = pnl.getParent();
        }
        return null;
    }

    public static <W extends Component & RootPaneContainer> void unmaskWindow(W window) {
        if (!window.isDisplayable()) {
            return;
        }
        window.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
        if (window.getGlassPane() != null) {
            window.getGlassPane().setVisible(false);
        }
    }
}

Related

  1. padPanel(Object innerPanel, JPanel outerPanel, int pad)
  2. removeComponentFromPanel(Component removeComponent, JPanel fromPanel)
  3. removePanel(JPanel parent, JPanel panel)
  4. resetControlsInAPanel(JPanel panel)
  5. resizeJPanel(JPanel p)
  6. wrapInMinimizer(JPanel panel)
  7. wrapMacFancy(JPanel content)