java的actionlistener小问题
importjava.io.*;importjava.util.*;importjava.text.*;importjava.lang.*;importstaticjav...
import java.io.*;
import java.util.*;
import java.text.*;
import java.lang.*;
import static java.lang.System.*;
import java.util.Set;
import java.util.HashSet;
import javax.swing.*;
import javax.*;
import java.awt.*;
import java.awt.event.*;
public class window
{
public static void main(String args[])throws Exception
{
JFrame W=new JFrame("Window");W.setSize(500,500);W.setVisible(true);//W.setBackground(Color.gray);
JButton Terry=new JButton("Terry");Terry.setSize(100,30);
JButton Hello=new JButton("Hello");Hello.setSize(100,30);
W.add(Terry);W.add(Hello);
Hello.setBounds(50,50,100,30);
ActionListener ear=new ActionListener(){
public void actionPerformed(ActionEvent even)
{
System.out.print(even.getActionCommand());
Terry.enable(false);//就在这,大家帮帮手
}
};
Hello.addActionListener(ear);
Terry.addActionListener(ear);
}
public void act()
{
//this.Hello.enable(false);
}
} 展开
import java.util.*;
import java.text.*;
import java.lang.*;
import static java.lang.System.*;
import java.util.Set;
import java.util.HashSet;
import javax.swing.*;
import javax.*;
import java.awt.*;
import java.awt.event.*;
public class window
{
public static void main(String args[])throws Exception
{
JFrame W=new JFrame("Window");W.setSize(500,500);W.setVisible(true);//W.setBackground(Color.gray);
JButton Terry=new JButton("Terry");Terry.setSize(100,30);
JButton Hello=new JButton("Hello");Hello.setSize(100,30);
W.add(Terry);W.add(Hello);
Hello.setBounds(50,50,100,30);
ActionListener ear=new ActionListener(){
public void actionPerformed(ActionEvent even)
{
System.out.print(even.getActionCommand());
Terry.enable(false);//就在这,大家帮帮手
}
};
Hello.addActionListener(ear);
Terry.addActionListener(ear);
}
public void act()
{
//this.Hello.enable(false);
}
} 展开
2个回答
展开全部
import java.io.*;
import java.util.*;
import java.text.*;
import java.lang.*;
import static java.lang.System.*;
import java.util.Set;
import java.util.HashSet;
import javax.swing.*;
import javax.*;
import java.awt.*;
import java.awt.event.*;
public class window
{
public static void main(String args[])throws Exception
{
JFrame W=new JFrame("Window");W.setSize(500,500);W.setVisible(true);//W.setBackground(Color.gray);
final JButton Terry=new JButton("Terry");Terry.setSize(100,30);
//注意上一行
JButton Hello=new JButton("Hello");Hello.setSize(100,30);
W.add(Terry);W.add(Hello);
Hello.setBounds(50,50,100,30);
ActionListener ear=new ActionListener(){
public void actionPerformed(ActionEvent even)
{
System.out.print(even.getActionCommand());
Terry.setEnabled(false);//就在这,大家帮帮手
}
};
Hello.addActionListener(ear);
Terry.addActionListener(ear);
}
public void act()
{
//this.Hello.enable(false);
}
}
import java.util.*;
import java.text.*;
import java.lang.*;
import static java.lang.System.*;
import java.util.Set;
import java.util.HashSet;
import javax.swing.*;
import javax.*;
import java.awt.*;
import java.awt.event.*;
public class window
{
public static void main(String args[])throws Exception
{
JFrame W=new JFrame("Window");W.setSize(500,500);W.setVisible(true);//W.setBackground(Color.gray);
final JButton Terry=new JButton("Terry");Terry.setSize(100,30);
//注意上一行
JButton Hello=new JButton("Hello");Hello.setSize(100,30);
W.add(Terry);W.add(Hello);
Hello.setBounds(50,50,100,30);
ActionListener ear=new ActionListener(){
public void actionPerformed(ActionEvent even)
{
System.out.print(even.getActionCommand());
Terry.setEnabled(false);//就在这,大家帮帮手
}
};
Hello.addActionListener(ear);
Terry.addActionListener(ear);
}
public void act()
{
//this.Hello.enable(false);
}
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询