用java awt更换图片_Java-每2秒更改图片

我会说一点,所以如果有人有任何想法,那将是有帮助的.

因此,当前程序正在编译并运行,但是我不知道如何完成它.

我正在使用日食.我想做的是,当我启动程序时每2秒更改4张不同的图片,因此,如果您有任何建议,请不要害羞.这是程序.

/** Here is the GUI of the program

* class name SlideShowGui.java

* @author Kiril Anastasov

* @date 07/03/2012

*/

import java.awt.*;

import java.awt.event.ActionEvent;

import java.awt.event.ActionListener;

import javax.swing.*;

public class SlideShowGui extends JPanel implements ActionListener

{

JLabel name, comments, images;

JTextField namejtf, commentsjtf, captionjtf;

JButton submit;

ImageIcon pictures, pictures2, pictures3, pictures4;

boolean go = true;

SlideShowGui()

{

name = new JLabel("Name:");

this.add(name);

namejtf = new JTextField(15);

this.add(namejtf);

comments = new JLabel("Comments:");

this.add(comments);

commentsjtf = new JTextField(15);

this.add(commentsjtf);

submit = new JButton("Submit");

this.add(submit);

submit.addActionListener(this);

pictures = new ImageIcon("galileo1.jpg");

images = new JLabel(pictures);

pictures2 = new ImageIcon("galileo2.jpg");

pictures3 = new ImageIcon("galileo3.jpg");

pictures4 = new ImageIcon("galileo4.jpg");

this.add(images);

captionjtf = new JTextField(24);

this.add(captionjtf);

}

public void actionPerformed(ActionEvent ae)

{

}

}

/**The driver class of the program. Here is the JFrame

* class name TestSlideShow.java

* @author Kiril Anastasov

* @date 07/03/2012

*/

import java.awt.*;

import javax.swing.*;

public class TestSlideShow

{

public static void main(String[] args)

{

JFrame application = new JFrame();

SlideShowGui panel = new SlideShowGui();

application.add(panel);

application.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

application.setSize(300,600);

application.setLocation(400,100);

application.setVisible(true);

}

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值