用java awt更换图片

阅读: 评论:0

用java awt更换图片

用java awt更换图片

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

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

我正在使用日食.我想做的是,当我启动程序时每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);

}

}

本文发布于:2024-02-04 15:17:19,感谢您对本站的认可!

本文链接:https://www.4u4v.net/it/170710356156641.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:图片   java   awt
留言与评论(共有 0 条评论)
   
验证码:

Copyright ©2019-2022 Comsenz Inc.Powered by ©

网站地图1 网站地图2 网站地图3 网站地图4 网站地图5 网站地图6 网站地图7 网站地图8 网站地图9 网站地图10 网站地图11 网站地图12 网站地图13 网站地图14 网站地图15 网站地图16 网站地图17 网站地图18 网站地图19 网站地图20 网站地图21 网站地图22/a> 网站地图23