Пример #1
0
  public void setActivo(boolean val) {
    glass.setVisible(val);
    setVisible(val);
    JLayeredPane.getLayeredPaneAbove(glass).moveToFront(glass);

    if (val) {
      synchronized (syncMonitor) {
        try {
          if (SwingUtilities.isEventDispatchThread()) {
            EventQueue theQueue = getToolkit().getSystemEventQueue();
            while (isVisible()) {
              AWTEvent event = theQueue.getNextEvent();
              Object source = event.getSource();

              if (event instanceof ActiveEvent) {
                ((ActiveEvent) event).dispatch();
              } else if (source instanceof Component) {
                ((Component) source).dispatchEvent(event);
              } else if (source instanceof MenuComponent) {
                ((MenuComponent) source).dispatchEvent(event);
              } else {
                System.out.println("No se puede despachar: " + event);
              }
            }
          } else {
            while (isVisible()) {
              syncMonitor.wait();
            }
          }
        } catch (InterruptedException ignored) {
          System.out.println("Excepción de interrupción: " + ignored.getMessage());
        }
      }
    } else {
      synchronized (syncMonitor) {
        setVisible(false);
        glass.setVisible(false);
        syncMonitor.notifyAll();

        eliminarDelContenedor();
      }
    }
  }
Пример #2
0
  public void fadeOut() {
    super.setVisible(true);

    try {
      final float desacel = 0.1f;
      while (BlurGlass.this.getAlpha() - desacel >= 0.0f) {
        SwingUtilities.invokeLater(
            new Runnable() {
              public void run() {
                BlurGlass.this.setAlpha(BlurGlass.this.getAlpha() - desacel);
              }
            });
        Thread.sleep(50);
      }
      BlurGlass.this.setAlpha(0.0f);
    } catch (Exception e) {
      Dialogos.error("Error en fadeout", e);
    }
    // super.setVisible(false);
    // BlurGlass.this.setAlpha(0.2f);
    // setAlpha(0.2f);
    super.setVisible(false);
  }
Пример #3
0
  public void fadeIn() {
    final float acel = 0.1f;
    generarFondo(this);
    super.setVisible(true);

    try {
      while (BlurGlass.this.getAlpha() + acel <= 1.0f) {
        SwingUtilities.invokeAndWait(
            new Runnable() {
              public void run() {
                BlurGlass.this.setAlpha(BlurGlass.this.getAlpha() + acel);
              }
            });
        Thread.sleep(50);
      }
    } catch (Exception e) {
      Dialogos.error("Error en fadein", e);
    }
  }
Пример #4
0
  public void init(Object parent) {

    glass = new BlurGlass();
    glass.setLayout(null);

    this.setLayout(null);

    setOpaque(false);
    // getContentPane().setOpaque(false);
    this.getLayeredPane().setOpaque(false);
    this.getRootPane().setOpaque(false);
    // putClientProperty("Synthetica.opaque", Boolean.FALSE);

    JParent = parent;
    glass.setOpaque(false);

    MouseInputAdapter adapter = new MouseInputAdapter() {};
    glass.addMouseListener(adapter);
    glass.addMouseMotionListener(adapter);

    try {
      if (parent instanceof JFrame) {
        layer = ((JFrame) parent).getLayeredPane();
      } else if (parent instanceof JInternalFrame) {
        layer = ((JInternalFrame) parent).getLayeredPane();
      }
      glass.setBounds(layer.getBounds());

    } catch (NullPointerException err) {
      Dialogos.error("Error interno en Dialogo interno modal", err);
    }

    try {
      glass.add(this);
      layer.add(glass, JLayeredPane.DEFAULT_LAYER);
    } catch (NullPointerException err) {
      Dialogos.error("Error interno en dialogo modal interno", err);
    }
  }