キャンバスには画像があり、画像の特定の部分に触れると、pointerPressed() メソッド内から新しいキャンバスを起動しようとしています。
出来ますか?これまでのところ、次のことを行っています。
protected void pointerPressed(int x, int y){
if ((x>=164 && x<=173)&&(y>=24 && y<=36)){
disp.setCurrent(new elementDetails());
}
}
クラスは次のとおりです。
//class to show detailed information of elements
class elementDetails extends Canvas{
private Image elmDtlImg;
public elementDetails(){
try{
elmDtlImg = Image.createImage("/details.jpg");
}
catch(IOException e){
System.out.println("Couldn't load Detailed Info image" + e.getMessage());
}
}
public void paint(Graphics g){
//set the drawing color to white
g.setGrayScale(255);
//draw a big white rectangle over the whole screen (over the previous screen)
g.fillRect(0, 0, getWidth(), getHeight());
g.drawImage(elmDtlImg, 0, 0, 20);
}
}
上記のコードを実行しても何も起こりません。現在の画像は、キャンバスに表示しようとしている新しい画像に変更されません。
私のアプリケーションは、ポインタが押されたイベントの後も実行を続けます。クラッシュしません。画像の他の部分の座標が正しく表示されます。私が達成しようとしているのはそれです。画像の特定のポイントをクリック/タッチすると、古いキャンバスの代わりに新しいキャンバスが読み込まれます。