java GUI中如何两个监听机制能够互相调用
importjava.awt.event.*;importjavax.swing.*;publicclassTextendsJFrameimplementsItemLis...
import java.awt.event.*;
import javax.swing.*;
public class T extends JFrame implements ItemListener,ActionListener{
JLabel jl;
JCheckBox jc1,jc2,jc3,jc4;
JButton jb1,jb2;
ImageIcon icon1 = new ImageIcon("a");
ImageIcon icon2 = new ImageIcon("2");
ImageIcon icon3 = new ImageIcon("#");
ImageIcon icon4 = new ImageIcon("b");
public T(){
super("测试");
jl = new JLabel("下面哪几个是字母:");
jc1 = new JCheckBox(icon1);
jc2 = new JCheckBox(icon2);
jc3 = new JCheckBox(icon3);
jc4 = new JCheckBox(icon4);
jb1 = new JButton("确定");
jb2 = new JButton("重置");
}
@Override
public void itemStateChanged(ItemEvent e) {
// TODO Auto-generated method stub
}
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
}
}
请问我想当点击确认后,判断点击的是哪,我该如何写itemStateChanged和actionPerformed,能帮我详细解释一下么 展开
import javax.swing.*;
public class T extends JFrame implements ItemListener,ActionListener{
JLabel jl;
JCheckBox jc1,jc2,jc3,jc4;
JButton jb1,jb2;
ImageIcon icon1 = new ImageIcon("a");
ImageIcon icon2 = new ImageIcon("2");
ImageIcon icon3 = new ImageIcon("#");
ImageIcon icon4 = new ImageIcon("b");
public T(){
super("测试");
jl = new JLabel("下面哪几个是字母:");
jc1 = new JCheckBox(icon1);
jc2 = new JCheckBox(icon2);
jc3 = new JCheckBox(icon3);
jc4 = new JCheckBox(icon4);
jb1 = new JButton("确定");
jb2 = new JButton("重置");
}
@Override
public void itemStateChanged(ItemEvent e) {
// TODO Auto-generated method stub
}
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
}
}
请问我想当点击确认后,判断点击的是哪,我该如何写itemStateChanged和actionPerformed,能帮我详细解释一下么 展开
- 你的回答被采纳后将获得:
- 系统奖励15(财富值+成长值)+难题奖励20(财富值+成长值)
1个回答
2015-08-07
展开全部
写成类的方法 ,就可以了
追问
怎么写,能帮忙举个例子么
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询