题目内容
当用户在文本框中输入6按回车键(如图),给出下列【代码】注释标注的代码的输出结果。import javax.swing.*;import java.awt.*;import java.awt.event.*;public class Win extends JFrame {JTextField text;public Win() {setLayout(new FlowLayout());text = new JTextField(8);text.addActionListener(new Listener());add(text);setBounds(10,10,460,360);setVisible(true);setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);}public static void main(String args[]){new Win();}}class Listener implements ActionListener {public void actionPerformed(ActionEvent e){JTextField text =(JTextField)e.getSource();int m = Integer.parseInt(text.getText());System.out.println(m*m);//【代码】}}
查看答案
搜索结果不匹配?点我反馈