?? calendarcyy.java.bak
字號:
import javax.microedition.lcdui.*;
import javax.microedition.midlet.*;
import java.util.*;
//import calendar.*;
public class calendarcyy extends MIDlet implements CommandListener,ImportDateFilter,DateSelectListener
{
private Command exitCommand,testCommand;
private TextBox tb;
private CalendarCanvas myCanvas;
private int[][]holiday ={{1,1},{3,8},{5,1},{6,1},{10,1}};
public calendarcyy()
{
exitCommand = new Command("Exit",Command.EXIT,9);
testCommand = new Command("Calendar",Command.SCREEN,1);
tb=new TextBox("demo","CalendarDemo MIDlet",40,0);
tb.addCommand(exitCommand);
tb.addCommand(textCommand);
tb.setCommandListener(this);
myCanvas = new CalendarCanvas(new Date());
myCanvas.setImportDateFilter(this);
myCanvas.setDateSelectListener(this);
myCanvas.addCommand(exitCommand);
myCanvas.setCommandListener(this);
}
protected void startApp() throws MIDletStateChangeException
{
Display.getDisplay(this).setCurrent(tb);
}
protected void pauseApp()
{
}
protected void destroyApp(boolean p1 )
{
}
public void commandAction(Command c,Displayable d)
{
if(c==exitCommand)
{
destroyApp(false);
notifyDestroyed();
}
else if(c==testCommand)
{
Display.getDisplay(this).setCurrent(myCanvas);
}
else if(d == myCanvas)
{
myCanvas.commandAction(c,d);
}
}
//實現ImportDateFilter接口,判斷日期類型
public int isImportantDate(Calendar date)
{
int dayOW=date.get(Calendar.DAY_OF_WEEK);
if(dayOW==Calendar.SATURDAY||dayOW==Calendar.SUNDAY)
{
//周末作為假日
return HOLIDAY;
}
int dayOM = date.get(Calendar.DAY_OF_MONTH);
int month = date.get(Calendar.MONTH);
for(int i=0;i<holiday.length;i++)
{
if(dayOM==holiday[i][1]&&month+1==holiday[i][0])
return HOLIDAY;
}
if(dayOM==2&&month==0)
{
return BOTH;
}
if((dayOM==26||dayOM==27)&&month==0)
{
return IMPORTANTDAY;
}
return NORMALDAY;
}
public void dateSelected(CalendarCanvas c,Calendar date)
{
Display.getDisplay(this).setCurrent(tb);
String dateStr = "date="+date.get(Calendar.YEAR)+"/";
dateStr+=(date.get(Calendar.MONTH)+1)+"/"+date.get(Calendar.DAY_OF_MONTH);
tb.setString(dateStr);
}
};
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -