📄 month.java
字号:
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
public class Month extends Box implements ActionListener
{
int month;
JTextField showMonth=null;
JButton 下月,上月;
CalendarPad 日历;
public Month(CalendarPad 日历){
super(BoxLayout.X_AXIS);
showMonth=new JTextField(2);
showMonth.setEditable(false);
showMonth.setForeground(Color.blue);
showMonth.setFont(new Font("TimesRomn",Font.BOLD,16));
this.日历=日历;
month=日历.getMonth();
上月=new JButton("上月");
下月=new JButton("下月");
add(上月);
add(showMonth);
add(下月);
showMonth.addActionListener(this);
上月.addActionListener(this);
下月.addActionListener(this);
showMonth.setText(" "+month);
}
public void setMonth(int month){
if(month<=12&&month>=1)
this.month=month;
else this.month=1;
showMonth.setText(" "+month);
}
public int getMonth(){
return month;
}
public void actionPerformed(ActionEvent e){
日历.put(new File("日历记事本.txt"));
if(e.getSource()==上月){
if(month>=2){
month=month-1;
日历.setMonth(month);
日历.设置日历牌(日历.getYear(),month);
}
else if(month==1){
month=12;
日历.setMonth(month);
日历.设置日历牌(日历.getYear(),month);
}
showMonth.setText(" "+month);
}
else if(e.getSource()==下月){
if(month<12){
month=month+1;
日历.setMonth(month);
日历.设置日历牌(日历.getYear(),month);
}
else if(month==12){
month=1;
日历.setMonth(month);
日历.设置日历牌(日历.getYear(),month);
}
showMonth.setText(" "+month);
try{
日历.notepad.设置信息条(日历.负责改变年.year,month,"1");
}catch(Exception ee){}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -