注册 登录
编程论坛 JAVA论坛

符号怎么改?

hhl0006 发布于 2016-07-04 14:07, 3119 次点击
import java.awt.*;
import java.awt.event.*;
import java.beans.*;
import
import java.util.*;
public class Calendar1 extends Panel implements Serializable,ActionListener
{
  protected Date date;
  protected GregorianCalendar calendar;
  protected Panel header=null;
  protected Panel body=null;
  protected Button prevMonth,nextMonth;
  protected Label monthLabel;
  protected String days=new String("星期天星期一星期二星期三星期四星期五星期六");
  protected String months=new String("一月二月三月四月五月六月七月八月九月十月十一月十二月");
  public Calendar1()
  {
    calendar=new GregorianCalendar();
    setSize(200,200);
    setLayout(new BorderLayout());
    header=new Panel();
    prevMonth=new Button("<<");
    prevMonth.addActionListener(this);
    nextMonth=new Button(">>");
    nextMonth.addActionListener(this);
    header.add(prevMonth);
    monthLabel=new Label(null,Label.CENTER);
    header.add(monthLabel);
    header.add(nextMonth);
    add("北方",header);
    body=new Panel();
    body.setLayout(new GridLayout(0,7));
    for(int i=0;i<21;i+=3)
    {
      body.add(new Label(days.substring(i,i+3),Label.CENTER));
    }
    add("中间",body);
    displayCalendar();
  }
  public synchronized Date getDate()
  {
    return calendar.getTime();
  }
  public synchronized void setDate(Date date)
  {
    calendar.setTime(date);
    displayCalendar();
  }
  protected synchronized void displayCalendar()
  {
    int yearNum=calendar.get(Calendar.YEAR);
    int monthNum=calendar.get(Calendar.MONTH);
    int dayNum=calendar.get(Calendar.DATE);
    String monthStr=months.substring(monthNum*3,monthNum*3+3);
    monthLabel.setText(monthStr+" " +yearNum);
    monthLabel.repaint();
    while(body.getComponentCount()>7)
      body.remove(7);
    calendar.set(Calendar.DATE,1);
    date=calendar.getTime();
    int day=date.getDay();
    for(int i=0;i<day;i++)
    {
      body.add(new Label());
    }
    Button dayBtn;
    for(int i=1;i<=32;i++)
    {
      dayBtn=new Button(new Integer(i).toString());
      dayBtn.addActionListener(this);
      body.add(dayBtn);
      calendar.add(Calendar.DATE,1);
      if(i==dayNum)
        dayBtn.requestFocus();
      if(calendar.get(Calendar.DATE)<=1)
        break;
    }
    calendar.set(yearNum,monthNum,dayNum);
    body.validate();
  }
  public synchronized void actionPerformed(ActionEvent e)
  {
    if(e.getSource()==prevMonth||e.getSource()==nextMonth)
    {
      calendar.set(Calendar.DATE,1);
      calendar.add(Calendar.MONTH,e.getSource()==prevMonth?-1:1);
      displayCalendar();
    }
    else
    {
      calendar.set(Calendar.DATE,Integer.parseInt(((Button)e.getSource()).getLabel()));
    }
    EventQueue.getEventQueue().postEvent(new MouseEvent(this,MouseEvent.MOUSE_CLICKED,0,0,0,0,1,true));
  }
}




6 回复
#2
hhl00062016-07-04 14:08
Microsoft Windows XP [版本 5.1.2600]
(C) 版权所有 1985-2001 Microsoft Corp.

C:\Documents and Settings\admin>g:

G:\>javac Calendar1.java
Calendar1.java:93: 错误: 找不到符号
    EventQueue.getEventQueue().postEvent(new MouseEvent(this,MouseEvent.MOUSE_CL
ICKED,0,0,0,0,1,true));
              ^
  符号:   方法 getEventQueue()
  位置: 类 EventQueue
注: Calendar1.java使用或覆盖了已过时的 API。
注: 有关详细信息, 请使用 -Xlint:deprecation 重新编译。
1 个错误

G:\>
#3
hhl00062016-07-07 07:57
恳请高手指点。
#4
hhl00062016-07-13 08:01
...
#5
hhl00062016-07-19 08:00
...
#6
aijiao06242016-07-19 14:23
不明白什么意思?
#7
hhl00062016-07-20 08:02
在shell窗口用javac 编译时显示上述错误提示。为什么呀?
1