画面にグラフを表示するアプリケーションに取り組んでいます。ペイント関数がチャートをレンダリングするカスタムフィールドを作成しました。ここで、この関数を呼び出してチャートを表示する方法を知りたいと思います。ここにサンプルコードを添付しましたが、表示されるのは空白の白い画面だけです。
public class Graph extends MainScreen
{
class MyField extends Field
{
protected void layout(int w,int h)
{
setExtent(getWidth(),getHeight());
}
protected void paint(Graphics g)
{
//my graph is drawn here
}
public MyField()
{
paint(getGraphics());
}
}
public Graph()
{
VerticalFieldManager vfm=new VerticalFieldManager();
vfm.add(new MyField());
add(vfm);
}
}