这个Java程序加载的图片为什么不显示
importjava.awt.event.*;importjavax.swing.*;publicclassImagePane2extendsJFrame{JLabelj...
import java.awt.event.*;
import javax.swing.*;
public class ImagePane2 extends JFrame{
JLabel jl=null;
ImageIcon img=null;
public ImagePane2(){
img=new ImageIcon("D:\\psb");
jl=new JLabel(img);
getContentPane().add(jl);
pack();
this.setVisible(true);
this.setSize(600,600);
this.setTitle("fdfdsdg");
addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e){System.exit(0);}});
}
public static void main(String[] args) {
new ImagePane2();
}
} 展开
import javax.swing.*;
public class ImagePane2 extends JFrame{
JLabel jl=null;
ImageIcon img=null;
public ImagePane2(){
img=new ImageIcon("D:\\psb");
jl=new JLabel(img);
getContentPane().add(jl);
pack();
this.setVisible(true);
this.setSize(600,600);
this.setTitle("fdfdsdg");
addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e){System.exit(0);}});
}
public static void main(String[] args) {
new ImagePane2();
}
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询