java imageName图片路径问题
我要把图片放哪个文件夹才能显示呀放了scrbin都不行packagetest;importjavax.swing.*;importjava.awt.*;publiccla...
我要把图片放哪个文件夹才能显示呀 放了scr bin都不行
package test;
import javax.swing.*;
import java.awt.*;
public class test{
public static void main(String args[]){
new MyWin();
}
}
class MyWin extends JFrame{
JTabbedPane p;
Icon icon[];
String imageName[]={"a.jpg","b.jpg","c.jpg","d.jpg","e.jpg"};
public MyWin(){
setBounds(100,100,500,300);
setVisible(true);
icon=new Icon[imageName.length];
for(int i=0;i<icon.length;i++)
icon[i]=new ImageIcon(imageName[i]);
p=new JTabbedPane(JTabbedPane.LEFT);
for(int i=0;i<icon.length;i++){
int m=i+1;
p.add("观看第"+m+"个图片",new JButton(icon[i]));
}
p.validate();
add(p,BorderLayout.CENTER);
validate();
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
}
} 展开
package test;
import javax.swing.*;
import java.awt.*;
public class test{
public static void main(String args[]){
new MyWin();
}
}
class MyWin extends JFrame{
JTabbedPane p;
Icon icon[];
String imageName[]={"a.jpg","b.jpg","c.jpg","d.jpg","e.jpg"};
public MyWin(){
setBounds(100,100,500,300);
setVisible(true);
icon=new Icon[imageName.length];
for(int i=0;i<icon.length;i++)
icon[i]=new ImageIcon(imageName[i]);
p=new JTabbedPane(JTabbedPane.LEFT);
for(int i=0;i<icon.length;i++){
int m=i+1;
p.add("观看第"+m+"个图片",new JButton(icon[i]));
}
p.validate();
add(p,BorderLayout.CENTER);
validate();
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
}
} 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询