0
誰でもJLabelに写真を読み込むことができますか? ATMはImageIOを認識しません。変数ImageIOを見つけることができません
private void doAnimation (int frame)
{
String str = Integer.toString(frame);
String selFrame = "f"+ str + ".png";
BufferedImage wPic = ImageIO.read(this.getClass().getResource(selFrame));
JLabel wIcon = new JLabel(new ImageIcon(wPic));
add(wIcon);
JLabel picLabel = new JLabel(new ImageIcon(wPic));
add(picLabel);
}
selFrameは、timerで生成されたpngファイルの名前です。フレームは、アプリケーションで使用されたときに関数にインポートされた数値です。ここで
は、コンストラクタで起動したタイマここif (actionEvent.getSource() == timerBackground)
{
if (backgroundNum == 42) backgroundNum = 1;
doAnimation(backgroundNum);
backgroundNum++;
}
のActionListenerのタイマです
timerBackground = new javax.swing.Timer (200, this);
あなたは
PaintComponenet
メソッドをオーバーライドして、画像の周りにtryキャッチ(IOExceptionを)ブロックを作成する必要があり
42種類のフレームがあります(gif->私はフレームに分解してアニメーションを行いたい) –