我有一个paneel.java 文件,它看起来像下面的代码:
import java.awt.*;
import javax.swing.*;
public class Paneel extends JFrame
{
public static void main ( String [] args )
{
// frame
JFrame frame = new Paneel();
frame.setSize ( 1000, 1000 );
frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
frame.setTitle( "Remembory" );
frame.setVisible( true );
}
class Gifpaneel extends JPanel{
private ImageIcon gif, animatedGif;
public Gifpaneel() {
gif = new ImageIcon( "test.gif" );
animatedGif = new ImageIcon( "animaties/test.gif" );
}
public void paintComponent( Graphics g ){
super.paintComponent( g );
gif.paintIcon( this, g, 100, 100 );
animatedGif.paintIcon ( this, g, 250, 100 );
}
}
}
我想展示 test.gif 文件。我该怎么做?因为当我在 Eclipse 中运行它时,我只得到没有图像的 jframe。