2012-03-07 152 views
3

我堆叠了一下,如果有人有任何想法,这将有所帮助。 所以目前该程序正在编译和运行,但我不知道如何完成它。 我正在使用eclipse。我想要做的是当我开始程序每2秒更换4张不同的图片,所以如果你有任何建议不要害羞。这是该计划。每2秒更换一张图片

/** 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); 


    } 

} 
+1

短简洁的问题,实际上说明在完全相同的问题通常有助于获得答案。 “帮助我完成计划”和一段代码让你看起来很慵懒,并且不会邀请人们回答。 – Durandal 2012-03-07 17:14:34

+0

嗯,我想每2秒更换一张图片 – Kiril 2012-03-07 17:19:06

回答