JTabbedPane 的问题
package cn.dadongzicool.example10_4;public class Example10_4 {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
new MyWin();
}
}
***********************************************
package cn.dadongzicool.example10_4;
import java.awt.BorderLayout;
import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JTabbedPane;
public 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);
//setBounds(100,100,100,100);
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]));
}
//JButton testButton = new JButton(icon[1]);
//add(testButton,BorderLayout.SOUTH);
p.validate();
add(p,BorderLayout.CENTER);
validate();
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}
代码如上,令有五张名字分别为a,b,c,d,e的jpg图片,但是运行的事后图片不能显示,请教一下!!!是什么原因?