a program in javabean to implement indexed properties of a bean using simplebeaninfo class
Aim: write a program in javabean to implement indexed properties of a bean using simplebeaninfo.
Program:
PieC.java
package sunw.demo.indexed;
import java.awt.*;
import java.io.*;
public class PieC
{
private
double data[ ];
public
double getData(int index)
{
return
data[index];
}
public void
setData(int index, double value)
{
data[index]
= value;
}
public
double[ ] getData( )
{
return
data;
}
public void
setData(double[ ] values)
{
data
= new double[values.length];
System.arraycopy(values,
0, data, 0, values.length);
}
}
PieCBeanInfo.java
package sunw.demo.indexed;
import java.beans.*;
public class PieCBeanInfo extends SimpleBeanInfo
{
public
PropertyDescriptor[] getPropertyDescriptors()
{
try
{
PropertyDescriptor data= new
PropertyDescriptor("data",PieC.class);
PropertyDescriptor p[] = {data};
return p;
}
catch(Exception e)
{
}
return null;
}
}
Output:
Labels: Advanced Java Lab
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home