Java Reference
In-Depth Information
Example
This example simply places an instance of AnimBean1 [See earlier part of this chap-
ter] onto the application frame, whereupon the juggler animation commences. Note
that the required GIF fi les must be on the system PAT H .
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import animBeans.AnimBean1; //Note this inclusion.
public class AnimBeanApp1 extends JFrame
{
public static void main(String[] args)
{
AnimBeanApp1 frame = new AnimBeanApp1();
frame.setSize(150,150);
frame.setVisible(true);
frame.setDefaultCloseOperation(EXIT_ON_CLOSE);
}
public AnimBeanApp1()
{
AnimBean1 sequence = new AnimBean1();
//Add bean to application frame…
add(sequence);
}
}
The resultant output is shown in Fig. 10.1 .
Fig. 10.1 JavaBean
animation running in a GUI
As an enhancement of this, we can make use of the 'set' methods in AnimBean2
to change the animation images and/or animation delay…
Example
 
Search WWH ::




Custom Search