关于读取图像的问题
怎样在jpanel中实现网页中的图像交互现实的效果
ImageIO?
xml?没时间看了
------解决方案--------------------import javax.swing.*;
import java.awt.*;
public class Test implements Runnable
{
JFrame f;
JPanel center;
JLabel m1,m2;
CardLayout myCard;
public Test()
{
f = new JFrame();
Container c = f.getContentPane();
center = new JPanel();
myCard = new CardLayout();
center.setLayout(myCard);
m1 = new JLabel( "第一个图片 ");
m2 = new JLabel( "第二个图片 ");
center.add( "m1 ",m1);
center.add( "m2 ",m2);
c.add(center, "Center ");
f.setSize(500,500);
f.setVisible(true);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
new Thread(this).start();
}
public static void main(String args[])
{
new Test();
}
public void run()
{
while(true)
{
myCard.previous(center);
try{Thread.sleep(2000);}catch(Exception e){}
}
}
}
乱写了一个,也算满足要求了,哈哈
每个JLabel上你设置一个图片就可以了,我懒得写啦