![](https://lstatic.shangxueba.com/jiandati/h5/images/m_q_title.png)
在Java事件处理模型中,当按下鼠标按钮时,处理()事件。
A.mouseReleased
B. mouseExited
C. mousePressed
D. mouseDow
A.mouseReleased
B. mouseExited
C. mousePressed
D. mouseDow
import j avax. swing. *;
import Java. awt. event. *;
class MiYal extends JPanel
{
JButton button[] =new JButton[3] ;
JTextField text;
MiYal()
{
for(int i=0; i<3; i++)
{
button[i] =new JButton("button0"+(i+1) ) ;
add(button[i] ) ;
}
text=new JTextField(10) ;
text. setHorizontalAlignment(JTextField. CENTER) ;
add(text) ;
}
}
public class C3801 implements ActionListener
{
JFrame. myWin:
MiYal panel;
C3801()
{
panel=new MiYal() ;
myWin=new JFrame("C3801") ;
myWin. add(panel) ;
myWin. setDefaultCloseOperation(JFrame. EXIT_ON_CLOSE. ;
for(int i=0; i<3; i++)
panel. button[i] . addActionListener(this) ;
myWin. pack() ;
myWin. setVisible(true) ;
}
public stalic void main(String[] args)
{
new C3801() ;
}
public void actionPerformed(ActionEvent e)
{
//这里是你要编写的代码
}
}
一、实验要求: 1、测试Java事件机制的4种实现方式; 2、结合JButton按钮事件,以及JComboBox控件的选择事件,实现两个控件jComboBox1,jComboBox2 内部的选项进行相互移动 3、测试两个JCheckBox的选择事件,即事件发生时,在JLabel中显示它们的状态信息; 4、测试两个JRadioButton的选择事件,即事件发生时,在JLabel中显示它们的状态信息; 5、利用两个按钮控件测试鼠标事件,其中,btnMouse(鼠标全部事件),btnMouseClick的(鼠标事件——单击效果); 二、本实验是针对事件交互代码的实现,其交互效果如下图所示:三、重要提示,可以参考如下代码框架,进行补充实现上述功能:
为了保护您的账号安全,请在“简答题”公众号进行验证,点击“官网服务”-“账号验证”后输入验证码“”完成验证,验证成功后方可继续查看答案!