题目内容

下列叙述错误的是()

A. JCheckBox选择框提供两种状态,一种是选中,另一种是未选中
B. JTextArea上不能触发MouseEvent事件
CheckBox选择框可以触发IteraEvent事件
D. JTextArea文本区的Document对象可以触发DocumentEvent事件

查看答案
更多问题

对于下列代码,叙述正确的是()import java.awt.*;import javax.swing.*;import java.awt.event.*;public class Win extends JFrame {JButton b;public Win() {setLayout(new FlowLayout());b = new JButton("yes");add(b);b.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e) {b.setText("ok");}});setVisible(true);setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);}public static void main(String args[]){new Win();}}

A. 窗口Win的布局是BorderLayout布局
B. 用户单击按钮b不会触发ActionEvent事件
C. 用户单击按钮b后,按钮上的名字改变成ok
D. 用户单击按钮b后,按钮上的名字仍然是yes

挑错题:A、B、C、D注释标注的哪行代码有错误?import javax.swing.*;import java.awt.*;public class Win extends JFrame {JTextField text;public Win() {setLayout(new FlowLayout()); //AsetLocation(500,400); //Btext = new TextField(8); //Cadd(text);setVisible(true);setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); //D}}

A
B
C
D

挑错题:A、B、C、D注释标注的哪行代码没有编译错误,但会触发NullPointerException运行异常??import javax.swing.*;import java.awt.*;import java.awt.event.*;public class Win extends JFrame implements ActionListener{JPanel panel;JButton button;public Win() {panel = new JPanel();panel.setLayout(new FlowLayout()); //Aadd(panel); //Bpanel.add(new JLabel("java"));button.addActionListener(this); //Cbutton = new JButton("enter");panel.add(button); //DsetBounds(10,10,460,360);setVisible(true);setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);}public void actionPerformed(ActionEvent e){}public static void main(String args[]) {Win win=new Win();}}

A
B
C
D

挑错题:A、B、C、D注释标注的哪行代码有错误?import javax.swing.*;import java.awt.*;import java.awt.event.*;public class Win extends JFrame implements ItemListener{JCheckBox c;public Win() {c = new JCheckBox("ok");c.setBackground(new Color(12,255,100)); //Ac.addItemListener(this); //Badd(c); //CsetBounds(10,10,460,360);setVisible(true);setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);}public void itemStateChanged(ItemEvent e){JCheckBox box = e.getSource(); //D}}

A
B
C
D

答案查题题库