谁帮我把这个Java程序注释一下,,万分感谢啦~ import java.awt.*; impo

谁帮我把这个Java程序注释一下,,万分感谢啦~importjava.awt.*;importjava.awt.event.*;importjavax.swing.*;p... 谁帮我把这个Java程序注释一下,,万分感谢啦~

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class JCalculator extends JFrame implements ActionListener {
private static final long serialVersionUID = -169068472193786457L;
private class WindowCloser extends WindowAdapter {
public void windowClosing(WindowEvent we) {
System.exit(0);
}
}
int i;
private final String[] str = { "7", "8", "9", "/", "4", "5", "6", "*", "1",
"2", "3", "-", ".", "0", "=", "+" };
JButton[] buttons = new JButton[str.length];
JButton reset = new JButton("CE");
JTextField display = new JTextField("0");
public JCalculator() {
super("Calculator");
JPanel panel1 = new JPanel(new GridLayout(4, 4));
for (i = 0; i < str.length; i++) {
buttons[i] = new JButton(str[i]);
panel1.add(buttons[i]);
}
JPanel panel2 = new JPanel(new BorderLayout());
panel2.add("Center", display);
panel2.add("East", reset);
getContentPane().setLayout(new BorderLayout());
getContentPane().add("North", panel2);
getContentPane().add("Center", panel1);
for (i = 0; i < str.length; i++)
buttons[i].addActionListener(this);
reset.addActionListener(this);
display.addActionListener(this);
addWindowListener(new WindowCloser());

setSize(800, 800);
setVisible(true);
pack();
}
public void actionPerformed(ActionEvent e) {
Object target = e.getSource();
String label = e.getActionCommand();
if (target == reset)
handleReset();
else if ("0123456789.".indexOf(label) > 0)
展开
 我来答
f592927502
推荐于2016-09-15 · 超过23用户采纳过TA的回答
知道答主
回答量:283
采纳率:0%
帮助的人:70.3万
展开全部
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class JCalculator extends JFrame implements ActionListener {
private static final long serialVersionUID = -169068472193786457L;

private class WindowCloser extends WindowAdapter {
//退出
public void windowClosing(WindowEvent we) {
System.exit(0);
}
}
int i;
//创建一个数组
private final String[] str = { "7", "8", "9", "/", "4", "5", "6", "*", "1",
"2", "3", "-", ".", "0", "=", "+" };

//新生成一个按钮数组,数组长度为str数组的长度
JButton[] buttons = new JButton[str.length];
//归零键
JButton reset = new JButton("CE");
//计算输出框
JTextField display = new JTextField("0");

public JCalculator() {
super("Calculator");
JPanel panel1 = new JPanel(new GridLayout(4, 4));
//循环计算器按钮
for (i = 0; i < str.length; i++) {
buttons[i] = new JButton(str[i]);
//将按钮依次添加到界面
panel1.add(buttons[i]);
}

JPanel panel2 = new JPanel(new BorderLayout());
//界面添加计算输出框
panel2.add("Center", display);
//界面添加归零按钮
panel2.add("East", reset);
getContentPane().setLayout(new BorderLayout());
//添加panel2在整体布局的上部
getContentPane().add("North", panel2);
//添加panel1在整体布局的中间
getContentPane().add("Center", panel1);

for (i = 0; i < str.length; i++)
//为计算按钮添加监听
buttons[i].addActionListener(this);
//为归零按钮按钮添加监听
reset.addActionListener(this);
//为计算输出框添加监听
display.addActionListener(this);
addWindowListener(new WindowCloser());

//设置窗体大小为800*800
setSize(800, 800);
//显示为true显示,false为隐藏
setVisible(true);
pack();
}
//方法不全
public void actionPerformed(ActionEvent e) {
Object target = e.getSource();
String label = e.getActionCommand();
if (target == reset)
handleReset();
else if ("0123456789.".indexOf(label) > 0)
更多追问追答
追问
还有一部分呢
可以注释完吗?
提利斯爱丽丝
2014-11-11 · 超过43用户采纳过TA的回答
知道小有建树答主
回答量:199
采纳率:0%
帮助的人:81.1万
展开全部
//import java.awt.*;
//import java.awt.event.*;
//import javax.swing.*;
//public class JCalculator extends JFrame implements ActionListener {
//private static final long serialVersionUID = -169068472193786457L;
//private class WindowCloser extends WindowAdapter {
// public void windowClosing(WindowEvent we) {
// System.exit(0);
// }
//}
//int i;
//private final String[] str = { "7", "8", "9", "/", "4", "5", "6", "*", "1",
// "2", "3", "-", ".", "0", "=", "+" };
//JButton[] buttons = new JButton[str.length];
//JButton reset = new JButton("CE");
//JTextField display = new JTextField("0");
//public JCalculator() {
// super("Calculator");
// JPanel panel1 = new JPanel(new GridLayout(4, 4));
// for (i = 0; i < str.length; i++) {
// buttons[i] = new JButton(str[i]);
// panel1.add(buttons[i]);
// }
// JPanel panel2 = new JPanel(new BorderLayout());
// panel2.add("Center", display);
// panel2.add("East", reset);
// getContentPane().setLayout(new BorderLayout());
// getContentPane().add("North", panel2);
// getContentPane().add("Center", panel1);
// for (i = 0; i < str.length; i++)
// buttons[i].addActionListener(this);
// reset.addActionListener(this);
// display.addActionListener(this);
// addWindowListener(new WindowCloser());
//
// setSize(800, 800);
// setVisible(true);
// pack();
//}
//public void actionPerformed(ActionEvent e) {
// Object target = e.getSource();
// String label = e.getActionCommand();
// if (target == reset)
// handleReset();
// else if ("0123456789.".indexOf(label) > 0)

OK注释完了
本回答被网友采纳
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式