我已经在努力了,而现在我的主类访问变量中:的Java:访问一个变量,它是一个ActionListener
public class Results extends JFrame {
public static void main(String[] args)
{
System.out.println(doble);
}}
这是一个ActionListener里面,像这样
public Results()
{
// Create a JPanel for the buttons DOUBLE AND NOT DOUBLE
JPanel duplicate = new JPanel(
new FlowLayout(FlowLayout.CENTER));
JButton doblebutton = new JButton("DOUBLE");
doblebutton.addActionListener(new ActionListener(){
private int doble;
public void actionPerformed(ActionEvent ae){
doble++;
System.out.println("Doubles: " + doble);
}
});
}
我已经尝试了5种方式来做到这一点,但似乎并不可行。有什么想法吗?
我会接受你的回答:)谢谢你。似乎我误解了一些东西!:) –