CartoonBeanpublic class CartoonBean extends Object implements SerializableThis is an example of a simple bean with one property that holds
names of image files. Every time the property is read, a new
file name is returned. |
Fields Summary |
---|
private static int | index | private List | fileNames |
Constructors Summary |
---|
public CartoonBean()Constructor that creates an internal data structure to hold
the image file names.
initFileList();
|
Methods Summary |
---|
public java.lang.String | getFileName()Returns a new file name every time it's called, cycling through
all available image files.
index++;
if (index > fileNames.size() - 1) {
index = 0;
}
return (String) fileNames.get(index);
| private void | initFileList()Creates and initializes a data structure to hold the image file
names.
fileNames = new ArrayList();
fileNames.add("dilbert2001113293109.gif");
fileNames.add("dilbert2001166171101.gif");
fileNames.add("dilbert2001166171108.gif");
fileNames.add("dilbert2731150011029.gif");
|
|