Java 使用“下一步”按钮显示一系列图像

Java 使用“下一步”按钮显示一系列图像,java,Java,如何在用户每次单击“下一步”按钮时逐个显示一系列图像? 我有几个图像存储在数组中。我用旁边的按钮从一个图像转到另一个图像。如何对按钮进行编程?我使用了action listener,但我不知道如何返回数组。我知道我在这里很懒,因为我没有编写完整的代码,但还是这样 class whatEver implements ActionListener{ JButton btnNext = new JButton(); static int fileNumber = 0; stat

如何在用户每次单击“下一步”按钮时逐个显示一系列图像?
我有几个图像存储在数组中。我用旁边的按钮从一个图像转到另一个图像。如何对按钮进行编程?我使用了action listener,但我不知道如何返回数组。

我知道我在这里很懒,因为我没有编写完整的代码,但还是这样

class whatEver implements ActionListener{
    JButton btnNext = new JButton();
    static int fileNumber = 0;
    static int totalFiles;

   void functionLoadInterface ()  //Function with
    {
        btnNext.addActionListener(this); 
        //Initialize array ImageArray with file paths.
    }

   public void cycleImage()
    { 
         String file = ImageArray[fileNumber%totalFiles];
         //Code to load the image wherever follows
    } 

   public void actionPerformed(ActionEvent e) 
    {
         filenumber++;
         this.cycleImage();
    }

有什么特别的语言吗?框架还有什么其他信息能让我们对你需要的帮助有一点了解吗?我会对按钮进行编程以转到下一张图片。我使用java。我不知道如何为按钮的动作侦听器编写。e、 如果(e.getSource()==buttonNext){…如何编程到下一个图像?也许你应该发布到目前为止的内容。谢谢大家…我还有一个问题…我不知道如何在JPanel上显示它。我在回答中添加了代码段。