Package de.anormalmedia.vividswinganimations.panels

Examples of de.anormalmedia.vividswinganimations.panels.AlphaPanel


        if( target instanceof JWindow ) {
            JWindow window = (JWindow)target;
            contentPane = window.getContentPane();
        }
        if( contentPane instanceof AlphaPanel ) {
            AlphaPanel aPanel = (AlphaPanel)contentPane;
            return new AlphaPanelAnimation( aPanel, targetAlpha );
        }

        return new ComponentFadeAnimation( target, targetAlpha );
    }
View Full Code Here


            itemPanel.validate();
            runner.start();
        }

        private AlphaPanel createItemPanel( String[] items ) {
            AlphaPanel panel = new AlphaPanel() {
                @Override
                public Dimension getPreferredSize() {
                    Dimension preferredSize = super.getPreferredSize();
                    preferredSize.height = (int)Math.floor( preferredSize.height * itemPanel.getAlpha() );
                    return preferredSize;
                }

                @Override
                public void validate() {
                    Dimension preferredSize = super.getPreferredSize();
                    Rectangle bounds = super.getBounds();
                    bounds.height = preferredSize.height;
                    setBounds( bounds );
                    if( runner == null || !runner.isRunning() ) {
                        super.validate();
                    }
                }

                @Override
                protected void validateTree() {
                    if( runner == null || !runner.isRunning() ) {
                        super.validateTree();
                    }
                }

                @Override
                public void setAlpha( float alpha ) {
                    super.setAlpha( alpha );
                    ExpandableAlphaPanel.this.revalidate();
                }
            };
            panel.setLayout( new GridLayout( items.length, 1 ) );
            panel.setBorder( new EmptyBorder( 0, 20, 0, 0 ) );

            for( String item : items ) {
                panel.add( new JCheckBox( item ) );
            }

            return panel;
        }
View Full Code Here

        JPanel ground = new JPanel();
        ground.setOpaque( true );
        ground.setBackground( Color.DARK_GRAY );
        contentPane.add( ground, JLayeredPane.DEFAULT_LAYER );

        AlphaPanel alphaPanel = new AlphaPanel();
        alphaPanel.setLayout( new BorderLayout() );
        alphaPanel.setAlpha( 0f );
        contentPane.add( alphaPanel, JLayeredPane.PALETTE_LAYER );

        JPanel exampleFadePanel = new JPanel( new BorderLayout() );
        exampleFadePanel.setOpaque( false );
        exampleFadePanel.setBorder( new CompoundBorder( new EmptyBorder( 20, 20, 20, 20 ), BorderFactory.createBevelBorder( BevelBorder.LOWERED ) ) );
        alphaPanel.add( exampleFadePanel, BorderLayout.CENTER );

        JLabel exampleLabel = new JLabel( "I'm the example" );
        exampleLabel.setHorizontalAlignment( SwingUtilities.CENTER );
        exampleLabel.setVerticalAlignment( SwingUtilities.CENTER );
        exampleLabel.setBackground( Color.BLACK );
        exampleLabel.setOpaque( true );
        exampleLabel.setForeground( Color.RED );
        exampleFadePanel.add( exampleLabel, BorderLayout.CENTER );

        final SlidePanel slidePanel = new SlidePanel( DIRECTION.fromLeft );
        slidePanel.setLayout( new BorderLayout() );
        contentPane.add( slidePanel, JLayeredPane.POPUP_LAYER );

        JPanel slideInExample = new JPanel( new BorderLayout() );
        slidePanel.add( slideInExample, BorderLayout.CENTER );
        slideInExample.setBackground( Color.BLUE );
        slideInExample.setOpaque( true );
        slideInExample.setBorder( BorderFactory.createLineBorder( Color.red, 2 ) );

        exampleLabel = new JLabel( "Sliding in and out ..." );
        exampleLabel.setHorizontalAlignment( SwingUtilities.CENTER );
        exampleLabel.setVerticalAlignment( SwingUtilities.CENTER );
        exampleLabel.setForeground( Color.RED );
        slideInExample.add( exampleLabel, BorderLayout.CENTER );

        setSize( 400, 300 );
        setVisible( true );
        Toolkit.getDefaultToolkit().setDynamicLayout( true );

        Rectangle r = new Rectangle( 0, 0, contentPane.getWidth(), contentPane.getHeight() );
        ground.setBounds( r );
        alphaPanel.setBounds( r );
        slidePanel.setBounds( 0, 0, 200, contentPane.getHeight() );

        DefaultAnimationRunner runner = new DefaultAnimationRunner();
        AlphaPanelAnimation fadeIn = new AlphaPanelAnimation( alphaPanel, 1f );
        fadeIn.setStartOffset( 1000 );
View Full Code Here

TOP

Related Classes of de.anormalmedia.vividswinganimations.panels.AlphaPanel

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.