求java对日期加减运算代码几处注释 代码已有且正确

import java.awt.*;
import java.awt.event.*;
import java.text.*;
import java.util.*;
import javax.swing.*;
public class SysDateTest {
public static void main(String[] args) {
new MainFrame();
}
}
class MainFrame extends JFrame implements ActionListener {
JButton btn1 = new JButton("button1");
JButton btn2 = new JButton("button2");

public MainFrame() {
this.setTitle("Main Frame");
this.setSize(200, 200);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

Container c = this.getContentPane();
c.setLayout(null);
btn1.setBounds(20, 20, 80, 20);
btn2.setBounds(20, 50, 80, 20);
c.add(btn1);
c.add(btn2);

btn1.addActionListener(this);
btn2.addActionListener(this);

int x = (int)((Toolkit.getDefaultToolkit().getScreenSize().getWidth() - this.getWidth())/2);
int y = (int)((Toolkit.getDefaultToolkit().getScreenSize().getHeight() - this.getHeight())/2); //这是什么意思
this.setLocation(x, y);
this.setVisible(true);
}

public void actionPerformed(ActionEvent event) {
Object source = event.getSource();
Date date = new Date();
if (source == btn1) {
new SubDialog(date, 0);
} else if (source == btn2) {
new SubDialog(date, 1); //0 1都是什么作用
}
}
}
class SubDialog extends JDialog implements ActionListener {
JButton btn1 = new JButton("calculate");
JButton btn2 = new JButton("close");
JTextField text = new JTextField();
JLabel label0 = new JLabel();
JLabel label1 = new JLabel();
JLabel label2 = new JLabel();
Date sysDate;
int dialogType = 0;
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
public SubDialog(Date date, int dialogType) {
this.setTitle("Sub Dialog");
this.setSize(360, 200);
this.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);

Container c = this.getContentPane();
c.setLayout(null);
label0.setBounds(20, 20, 200, 20);
text.setBounds(20, 50, 80, 20);
label1.setBounds(110, 50, 240, 20);
label2.setBounds(20, 80, 160, 20);
btn1.setBounds(20, 110, 80, 20);
btn2.setBounds(110, 110, 80, 20);
c.add(label0);
c.add(text);
c.add(label1);
c.add(label2);
c.add(btn1);
c.add(btn2);
第二部分在这 只要3处注释 谢谢http://zhidao.baidu.com/question/95298331.html
=============================================================================-
谢谢回答 明白了 那如果我要是把第2项拆开怎么写呢
不用这么分配 而是按了btn1就进入一个标签 按了btn2就入另一个标签

public SubDialog(Date date, int dialogType) 这句是什么意思呢?

int y = (int)((Toolkit.getDefaultToolkit().getScreenSize().getHeight() - this.getHeight())/2); 让窗口居中

new SubDialog(date, 1); //0 1都是什么作用
根据按钮的不同来定一个标签,btn1为0,btn2为1,0为一种dialog“类型”,1为另一种dialog“类型”,这个是根据他的词意来的

第三个;
add(int field, int amount)
根据日历的规则,为给定的日历字段添加或减去指定的时间量。
c2.add(Calendar.DATE, -1);-1的意思是减去一天的意思如果是+1的话,就是加一天的意思
温馨提示:答案为网友推荐,仅供参考
第1个回答  2009-04-28
1 让窗口居于屏幕中间
2 根据传入值的不同分别显示不同的标签文字
3 让日历后退一天