FileDocCategorySizeDatePackage
TransitionTabbedPane.javaAPI DocExample1969Mon Jan 09 11:01:58 GMT 2006None

TransitionTabbedPane

public class TransitionTabbedPane extends JTabbedPane implements Runnable, ChangeListener

Fields Summary
protected int
step
protected BufferedImage
buf
protected int
previous_tab
protected int
animation_length
Constructors Summary
public TransitionTabbedPane()


      
        super();
        this.addChangeListener(this);
    
Methods Summary
public intgetAnimationLength()

        return this.animation_length;
    
public static voidp(java.lang.String s)

        System.out.println(s);
    
public voidpaintChildren(java.awt.Graphics g)

        super.paintChildren(g);
        
        if(step != -1) {
            Rectangle size = this.getComponentAt(0).getBounds();
            Graphics2D g2 = (Graphics2D)g;
            paintTransition(g2, step, size, buf);
        }
    
public voidpaintTransition(java.awt.Graphics2D g2, int step, java.awt.Rectangle size, java.awt.Image prev)

    
public voidrun()

        step = 0;
        
        // save the previous tab
        if(previous_tab != -1) {
            Component comp = this.getComponentAt(previous_tab);
            buf = new BufferedImage(comp.getWidth(),
                comp.getHeight(),
                BufferedImage.TYPE_4BYTE_ABGR);
            comp.paint(buf.getGraphics());
        }
        
        for(int i=0; i<animation_length; i++) {
            step = i;
            repaint();
            try {
                Thread.currentThread().sleep(100);
            } catch (Exception ex) {
                p("ex: " + ex);
            }
        }
        
        step = -1;
        previous_tab = this.getSelectedIndex();
        repaint();
    
public voidsetAnimationLength(int length)

        this.animation_length = length;
    
public voidstateChanged(javax.swing.event.ChangeEvent evt)

        new Thread(this).start();