我要实现标题所说的功能,但是参数去却没有办法传递,
请问,怎么样才可以将事件处理程序中的参数传出来呢?
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
public class jframe {
public static void main(String[] args) {
JFrame jj=new JFrame("adjust");
int size=200;
JButton big=new JButton("BIG");
JButton small=new JButton("SMALL");
big.addActionListener(new ActionListener(){
protected int i=1;
public void actionPerformed(ActionEvent e)
{
System.out.println(i++);
}
});
small.addActionListener(new ActionListener(){
protected int j=20;
public void actionPerformed(ActionEvent e)
{
System.out.println(j++);
}
});
jj.addWindowListener(new WindowAdapter()
{
public void WindowClosing(WindowEvent e)
{
System.exit(0);
}
});
jj.getContentPane().add(big,"North");
jj.getContentPane().add(small,"South");
jj.setSize(size,size);
jj.setVisible(true);
}
}