Java Window hideWaitPane(Window win, Timer timer)

Here you can find the source of hideWaitPane(Window win, Timer timer)

Description

hide Wait Pane

License

LGPL

Declaration

public static void hideWaitPane(Window win, Timer timer) 

Method Source Code

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

import java.awt.Component;
import java.awt.Container;

import java.awt.Window;

import javax.swing.JComponent;
import javax.swing.JDialog;

import javax.swing.JFrame;

import javax.swing.JPanel;

import javax.swing.Timer;

public class Main {

    public static void hideWaitPane(Window win, Timer timer) {
        JPanel pane = new JPanel();
        pane.setOpaque(false);//  w ww . j  av a 2  s  .co m
        if (win instanceof JFrame) {
            JFrame frame = (JFrame) win;
            frame.setGlassPane(pane);

        } else if (win instanceof JDialog) {
            JDialog dialog = (JDialog) win;
            dialog.setGlassPane(pane);
        } else {
            throw new IllegalArgumentException("just JFrame and JDialog is support at present");
        }
        pane.setVisible(false);

        if (timer != null) {
            timer.stop();
            timer = null;
        }

        win.repaint();
    }

    public static void setGlassPane(JComponent comp, Component glass, boolean visible) {
        Container container = comp.getTopLevelAncestor();
        if (container instanceof JFrame) {
            JFrame frame = (JFrame) container;
            frame.setGlassPane(glass);
        } else if (container instanceof JDialog) {
            JDialog dialog = (JDialog) container;
            dialog.setGlassPane(glass);
        } else {
            throw new RuntimeException("unsupported top level ancestor!");
        }
        glass.setVisible(visible);
    }
}

Related

  1. getWindow(String title)
  2. getWindowNormalBounds(Window window)
  3. getWindowTitle(Window window)
  4. getWindowTitle(Window window)
  5. growIfNecessary(Window window)
  6. installPrefsHandler(final Preferences prefs, final String name, Window window)
  7. isResizable(Window window)
  8. modifyDimensions(Window window)
  9. openWindow(final JPanel panel)