报着希望,看有人回答没,100分,顶者都有分吧 看以下程序,如何实现2个框架的通信?
import java.awt.BorderLayout;
import javax.swing.JFrame;
import javax.swing.JLabel;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import javax.swing.ImageIcon;
import java.awt.event.ActionListener;
import javax.swing.Timer;
import java.awt.event.ActionEvent;
import java.io.File;
public class full_Frame extends JFrame {
BorderLayout borderLayout1 = new BorderLayout();
static Timer AutoTimer;
ImageIcon icon = new ImageIcon( "./src/image/1.jpg ");
JLabel jLabel1 = new JLabel(icon);
private String[] getFile()
{
File f=new File( "./src/image/ ");
return f.list();
}
int i=1;
String[] files=getFile();
public full_Frame() {
try {
jbInit();
} catch (Exception exception) {
exception.printStackTrace();
}
}
public void jbInit() throws Exception {
getContentPane().setLayout(borderLayout1);
this.getContentPane().add(jLabel1, java.awt.BorderLayout.CENTER);
AutoTimer = new Timer(3000, new ActionListener() {
public void actionPerformed(ActionEvent e) {
if (i ==files.length-1)
i = 1;
icon = new ImageIcon( "./src/image/ " + files[i]);
jLabel1.setIcon(icon);
jLabel1.repaint();
i++;
}