📄 month.java
字号:
/*
* month.java
*
* Created on 2007年4月4日, 下午10:22
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package month;
/**
*
* @author mgc
*/
import java.awt.*;
import java.awt.event.*;
public class month {
public static void main(String args[])
{
new FrameInOut();
}
}
class FrameInOut extends Frame implements ActionListener
{
Label prompt,output;
TextField input;
FrameInOut()
{
super("月份天数显示程序");
prompt=new Label("请输入月份:");
input=new TextField(6);
output=new Label(" ");
setLayout(new FlowLayout());
add(prompt);
add(input);
add(output);
input.addActionListener(this);
setSize(300,200);
show();
}
public void actionPerformed(ActionEvent e)
{
int m,day;
m=Integer.parseInt(input.getText());
if (m>=1 && m<=12)
{
switch(m)
{
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12: day=31;break;
case 2: day=28;break;
default:day=30;
}
output.setText(m+"月有"+day+"天");
}
else
{
output.setText("输入错误,请重新输入!");
input.setText("");
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -