📄 month.java
字号:
/* * To change this template, choose Tools | Templates * and open the template in the editor. */package 日历记事本;/** * * @author Administrator */import javax.swing.*;import java.awt.*;import java.awt.event.*;public class Month extends Box implements ActionListener{ int month; JTextField showMonth=null; JButton 下月,上月; CalendarPad 日历; public Month(CalendarPad 日历) { super(BoxLayout.X_AXIS); this.日历=日历; showMonth=new JTextField(2); month=日历.getMonth(); showMonth.setEditable(false); showMonth.setForeground(Color.blue); showMonth.setFont(new Font("TimesRomn",Font.BOLD,16)); 下月=new JButton("下月"); 上月=new JButton("上月"); add(上月); add(showMonth); add(下月); 上月.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) { 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); } } }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -