紧急求助!给该Java程序作注释
/***@(#)MyCalendar.java*@authorfancy*/packagefancy;importjava.awt.*;importjava.awt.ev...
/**
* @(#) MyCalendar.java
* @author fancy
*/
package fancy;
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.table.*;
public class MyCalendar extends JApplet {
public static final String WEEK_SUN = "SUN";
public static final String WEEK_MON = "MON";
public static final String WEEK_TUE = "TUE";
public static final String WEEK_WED = "WED";
public static final String WEEK_THU = "THU";
public static final String WEEK_FRI = "FRI";
public static final String WEEK_SAT = "SAT";
public static final Color background = Color.white;
public static final Color foreground = Color.black;
public static final Color headerBackground = Color.blue;
public static final Color headerForeground = Color.white;
public static final Color selectedBackground = Color.blue;
public static final Color selectedForeground = Color.white;
private JPanel cPane;
private JLabel yearsLabel;
private JSpinner yearsSpinner;
private JLabel monthsLabel;
private JComboBox monthsComboBox;
private JTable daysTable;
private AbstractTableModel daysModel;
private Calendar calendar;
public MyCalendar() {
cPane = (JPanel) getContentPane();
}
public void init() {
cPane.setLayout(new BorderLayout());
calendar = Calendar.getInstance();
calendar = Calendar.getInstance();
yearsLabel = new JLabel("Year: ");
yearsSpinner = new JSpinner();
yearsSpinner.setEditor(new JSpinner.NumberEditor(yearsSpinner, "0000"));
yearsSpinner.setValue(new Integer(calendar.get(Calendar.YEAR)));
yearsSpinner.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent changeEvent) {
int day = calendar.get(Calendar.DAY_OF_MONTH);
calendar.set(Calendar.DAY_OF_MONTH, 1);
calendar.set(Calendar.YEAR, ((Integer) yearsSpinner.getValue()).intValue());
int maxDay = calendar.getActualMaximum(Calendar.DAY_OF_MONTH);
calendar.set(Calendar.DAY_OF_MONTH, day > maxDay ? maxDay : day);
updateView();
}
});
JPanel yearMonthPanel = new JPanel();
cPane.add(yearMonthPanel, BorderLayout.NORTH);
yearMonthPanel.setLayout(new BorderLayout());
yearMonthPanel.add(new JPanel(), BorderLayout.CENTER);
JPanel yearPanel = new JPanel();
yearMonthPanel.add(yearPanel, BorderLayout.WEST);
yearPanel.setLayout(new BorderLayout());
yearPanel.add(yearsLabel, BorderLayout.WEST);
yearPanel.add(yearsSpinner, BorderLayout.CENTER); 展开
* @(#) MyCalendar.java
* @author fancy
*/
package fancy;
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.table.*;
public class MyCalendar extends JApplet {
public static final String WEEK_SUN = "SUN";
public static final String WEEK_MON = "MON";
public static final String WEEK_TUE = "TUE";
public static final String WEEK_WED = "WED";
public static final String WEEK_THU = "THU";
public static final String WEEK_FRI = "FRI";
public static final String WEEK_SAT = "SAT";
public static final Color background = Color.white;
public static final Color foreground = Color.black;
public static final Color headerBackground = Color.blue;
public static final Color headerForeground = Color.white;
public static final Color selectedBackground = Color.blue;
public static final Color selectedForeground = Color.white;
private JPanel cPane;
private JLabel yearsLabel;
private JSpinner yearsSpinner;
private JLabel monthsLabel;
private JComboBox monthsComboBox;
private JTable daysTable;
private AbstractTableModel daysModel;
private Calendar calendar;
public MyCalendar() {
cPane = (JPanel) getContentPane();
}
public void init() {
cPane.setLayout(new BorderLayout());
calendar = Calendar.getInstance();
calendar = Calendar.getInstance();
yearsLabel = new JLabel("Year: ");
yearsSpinner = new JSpinner();
yearsSpinner.setEditor(new JSpinner.NumberEditor(yearsSpinner, "0000"));
yearsSpinner.setValue(new Integer(calendar.get(Calendar.YEAR)));
yearsSpinner.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent changeEvent) {
int day = calendar.get(Calendar.DAY_OF_MONTH);
calendar.set(Calendar.DAY_OF_MONTH, 1);
calendar.set(Calendar.YEAR, ((Integer) yearsSpinner.getValue()).intValue());
int maxDay = calendar.getActualMaximum(Calendar.DAY_OF_MONTH);
calendar.set(Calendar.DAY_OF_MONTH, day > maxDay ? maxDay : day);
updateView();
}
});
JPanel yearMonthPanel = new JPanel();
cPane.add(yearMonthPanel, BorderLayout.NORTH);
yearMonthPanel.setLayout(new BorderLayout());
yearMonthPanel.add(new JPanel(), BorderLayout.CENTER);
JPanel yearPanel = new JPanel();
yearMonthPanel.add(yearPanel, BorderLayout.WEST);
yearPanel.setLayout(new BorderLayout());
yearPanel.add(yearsLabel, BorderLayout.WEST);
yearPanel.add(yearsSpinner, BorderLayout.CENTER); 展开
5个回答
展开全部
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.table.*;
/*JApplet是java.applet.Applet 的扩展版*/
public class MyCalendar extends JApplet {
/**
* 静态常量设置星期几(英文的简写)
* */
public static final String WEEK_SUN = "SUN";
public static final String WEEK_MON = "MON";
public static final String WEEK_TUE = "TUE";
public static final String WEEK_WED = "WED";
public static final String WEEK_THU = "THU";
public static final String WEEK_FRI = "FRI";
public static final String WEEK_SAT = "SAT";
/**
* 静态常量设置颜色
* */
public static final Color background = Color.white;
public static final Color foreground = Color.black;
public static final Color headerBackground = Color.blue;
public static final Color headerForeground = Color.white;
public static final Color selectedBackground = Color.blue;
public static final Color selectedForeground = Color.white;
private JPanel cPane; //是一般轻量级容器
private JLabel yearsLabel; //用于短文本字符串或图像或二者的显示区
/*让用户从一个有序序列中选择一个数字或者一个对象值的单行输入字段。*/
private JSpinner yearsSpinner;
private JLabel monthsLabel;
private JComboBox monthsComboBox;//下拉框
private JTable daysTable; //表格
private AbstractTableModel daysModel; //table的model
private Calendar calendar; //处理日期的类
public MyCalendar() {
cPane = (JPanel) getContentPane(); //返回此窗体的 contentPane 对象
}
public void init() {
cPane.setLayout(new BorderLayout());//设置布局方式为边框布局
calendar = Calendar.getInstance();
calendar = Calendar.getInstance();
yearsLabel = new JLabel("Year: ");
yearsSpinner = new JSpinner();
/* 更改显示 SpinnerModel 当前值的 JComponent */
yearsSpinner.setEditor(new JSpinner.NumberEditor(yearsSpinner, "0000"));
/*更改模型的当前值,通常此值是 editor 所显示的值。*/
yearsSpinner.setValue(new Integer(calendar.get(Calendar.YEAR)));
/*为每次发生模型更改时要通知的列表添加侦听器。匿名内部类中做具体操作*/
yearsSpinner.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent changeEvent) {
int day = calendar.get(Calendar.DAY_OF_MONTH);
calendar.set(Calendar.DAY_OF_MONTH, 1);
calendar.set(Calendar.YEAR, ((Integer) yearsSpinner.getValue()).intValue());
int maxDay = calendar.getActualMaximum(Calendar.DAY_OF_MONTH);
calendar.set(Calendar.DAY_OF_MONTH, day > maxDay ? maxDay : day);
updateView();
}
});
JPanel yearMonthPanel = new JPanel();
/*将组建添加到容器中,并布局*/
cPane.add(yearMonthPanel, BorderLayout.NORTH);
yearMonthPanel.setLayout(new BorderLayout());
yearMonthPanel.add(new JPanel(), BorderLayout.CENTER);
JPanel yearPanel = new JPanel();
/*将组建添加到容器中,并布局*/
yearMonthPanel.add(yearPanel, BorderLayout.WEST);
yearPanel.setLayout(new BorderLayout());
yearPanel.add(yearsLabel, BorderLayout.WEST);
yearPanel.add(yearsSpinner, BorderLayout.CENTER);
你程序黏贴的补全,已经注释完毕!希望对你有所帮助!
import java.awt.event.*;
import java.util.*;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.table.*;
/*JApplet是java.applet.Applet 的扩展版*/
public class MyCalendar extends JApplet {
/**
* 静态常量设置星期几(英文的简写)
* */
public static final String WEEK_SUN = "SUN";
public static final String WEEK_MON = "MON";
public static final String WEEK_TUE = "TUE";
public static final String WEEK_WED = "WED";
public static final String WEEK_THU = "THU";
public static final String WEEK_FRI = "FRI";
public static final String WEEK_SAT = "SAT";
/**
* 静态常量设置颜色
* */
public static final Color background = Color.white;
public static final Color foreground = Color.black;
public static final Color headerBackground = Color.blue;
public static final Color headerForeground = Color.white;
public static final Color selectedBackground = Color.blue;
public static final Color selectedForeground = Color.white;
private JPanel cPane; //是一般轻量级容器
private JLabel yearsLabel; //用于短文本字符串或图像或二者的显示区
/*让用户从一个有序序列中选择一个数字或者一个对象值的单行输入字段。*/
private JSpinner yearsSpinner;
private JLabel monthsLabel;
private JComboBox monthsComboBox;//下拉框
private JTable daysTable; //表格
private AbstractTableModel daysModel; //table的model
private Calendar calendar; //处理日期的类
public MyCalendar() {
cPane = (JPanel) getContentPane(); //返回此窗体的 contentPane 对象
}
public void init() {
cPane.setLayout(new BorderLayout());//设置布局方式为边框布局
calendar = Calendar.getInstance();
calendar = Calendar.getInstance();
yearsLabel = new JLabel("Year: ");
yearsSpinner = new JSpinner();
/* 更改显示 SpinnerModel 当前值的 JComponent */
yearsSpinner.setEditor(new JSpinner.NumberEditor(yearsSpinner, "0000"));
/*更改模型的当前值,通常此值是 editor 所显示的值。*/
yearsSpinner.setValue(new Integer(calendar.get(Calendar.YEAR)));
/*为每次发生模型更改时要通知的列表添加侦听器。匿名内部类中做具体操作*/
yearsSpinner.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent changeEvent) {
int day = calendar.get(Calendar.DAY_OF_MONTH);
calendar.set(Calendar.DAY_OF_MONTH, 1);
calendar.set(Calendar.YEAR, ((Integer) yearsSpinner.getValue()).intValue());
int maxDay = calendar.getActualMaximum(Calendar.DAY_OF_MONTH);
calendar.set(Calendar.DAY_OF_MONTH, day > maxDay ? maxDay : day);
updateView();
}
});
JPanel yearMonthPanel = new JPanel();
/*将组建添加到容器中,并布局*/
cPane.add(yearMonthPanel, BorderLayout.NORTH);
yearMonthPanel.setLayout(new BorderLayout());
yearMonthPanel.add(new JPanel(), BorderLayout.CENTER);
JPanel yearPanel = new JPanel();
/*将组建添加到容器中,并布局*/
yearMonthPanel.add(yearPanel, BorderLayout.WEST);
yearPanel.setLayout(new BorderLayout());
yearPanel.add(yearsLabel, BorderLayout.WEST);
yearPanel.add(yearsSpinner, BorderLayout.CENTER);
你程序黏贴的补全,已经注释完毕!希望对你有所帮助!
展开全部
这是一个关于日历的Applet小程序,最上面的是日历的一些必须的元素及属性的变量定义声明,init()中是对日历的属性初始化,其中stateChanged()中是对触发事件日历的更新设置,最下边的是各个属性面板在整个applet中的布局。
由于代码过长,不一一注释了,但愿说的这些对您有帮助。
由于代码过长,不一一注释了,但愿说的这些对您有帮助。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
// 注释单行
/**
注释多行
**/
/**
注释多行
**/
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
/*set number*/
/*set colour*/
/*main method*/
/*set colour*/
/*main method*/
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
// 注释单行
/**
注释多行
**/
/**
注释多行
**/
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询