Java Code Examples for org.jdesktop.swingx.JXPanel#setAlpha()

The following examples show how to use org.jdesktop.swingx.JXPanel#setAlpha() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Stacker.java    From littleluck with Apache License 2.0 5 votes vote down vote up
/**
 * Fades in the specified message component in the top layer of this
 * layered pane.
 * @param message the component to be displayed in the message layer
 * @param finalAlpha the alpha value of the component when fade in is complete
 */
public void showMessageLayer(JComponent message, final float finalAlpha) {
    messageLayer = new JPanel();
    messageLayer.setOpaque(false);
    GridBagLayout gridbag = new GridBagLayout();
    messageLayer.setLayout(gridbag);
    GridBagConstraints c = new GridBagConstraints();
    c.anchor = GridBagConstraints.CENTER;

    messageAlpha = new JXPanel();
    messageAlpha.setOpaque(false);
    messageAlpha.setAlpha(0.0f);
    gridbag.addLayoutComponent(messageAlpha, c);
    messageLayer.add(messageAlpha);
    messageAlpha.add(message);

    add(messageLayer, JLayeredPane.POPUP_LAYER);
    revalidate();
    SwingUtilities.invokeLater(new Runnable() {
        public void run() {
            Animator animator = new Animator(2000,
                    new PropertySetter(messageAlpha, "alpha", 0.0f, finalAlpha));
            animator.setStartDelay(200);
            animator.setAcceleration(.2f);
            animator.setDeceleration(.5f);
            animator.start();
        }
    });
}
 
Example 2
Source File: Stacker.java    From beautyeye with Apache License 2.0 5 votes vote down vote up
/**
 * Fades in the specified message component in the top layer of this
 * layered pane.
 * @param message the component to be displayed in the message layer
 * @param finalAlpha the alpha value of the component when fade in is complete
 */
public void showMessageLayer(JComponent message, final float finalAlpha) {
    messageLayer = new JPanel();
    messageLayer.setOpaque(false);
    GridBagLayout gridbag = new GridBagLayout();
    messageLayer.setLayout(gridbag);
    GridBagConstraints c = new GridBagConstraints();
    c.anchor = GridBagConstraints.CENTER;

    messageAlpha = new JXPanel();
    messageAlpha.setOpaque(false);
    messageAlpha.setAlpha(0.0f);
    gridbag.addLayoutComponent(messageAlpha, c);
    messageLayer.add(messageAlpha);
    messageAlpha.add(message);

    add(messageLayer, JLayeredPane.POPUP_LAYER);
    revalidate();
    SwingUtilities.invokeLater(new Runnable() {
        public void run() {
            Animator animator = new Animator(2000,
                    new PropertySetter(messageAlpha, "alpha", 0.0f, finalAlpha));
            animator.setStartDelay(200);
            animator.setAcceleration(.2f);
            animator.setDeceleration(.5f);
            animator.start();
        }
    });
}
 
Example 3
Source File: Stacker.java    From Darcula with Apache License 2.0 5 votes vote down vote up
/**
 * Fades in the specified message component in the top layer of this
 * layered pane.
 * @param message the component to be displayed in the message layer
 * @param finalAlpha the alpha value of the component when fade in is complete
 */
public void showMessageLayer(JComponent message, final float finalAlpha) {
    messageLayer = new JPanel();
    messageLayer.setOpaque(false);
    GridBagLayout gridbag = new GridBagLayout();
    messageLayer.setLayout(gridbag);
    GridBagConstraints c = new GridBagConstraints();
    c.anchor = GridBagConstraints.CENTER;

    messageAlpha = new JXPanel();
    messageAlpha.setOpaque(false);
    messageAlpha.setAlpha(0.0f);
    gridbag.addLayoutComponent(messageAlpha, c);
    messageLayer.add(messageAlpha);
    messageAlpha.add(message);

    add(messageLayer, JLayeredPane.POPUP_LAYER);
    revalidate();
    SwingUtilities.invokeLater(new Runnable() {
        public void run() {
            Animator animator = new Animator(2000,
                    new PropertySetter(messageAlpha, "alpha", 0.0f, finalAlpha));
            animator.setStartDelay(200);
            animator.setAcceleration(.2f);
            animator.setDeceleration(.5f);
            animator.start();
        }
    });
}