java日历和钟表代码
发布网友
发布时间:2022-05-27 15:04
我来回答
共1个回答
热心网友
时间:2023-10-29 19:10
import hysun.util.MonthlyCalendar;
import javax.swing.*;
import java.awt.*;
public class TestMC extends JFrame {
public TestMC() {
final JTextField textfield = new JTextField();
getContentPane().add(textfield, BorderLayout.NORTH);
MonthlyCalendar mc = new MonthlyCalendar() {
protected void dateSelected() {
textfield.setText(getYear()+"."+getMonth()+"."+getSelectedDay());
}
};
mc.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
mc.setYearMonth(2005, 2);
getContentPane().add(mc);
setDefaultCloseOperation(EXIT_ON_CLOSE);
pack();
setLocationRelativeTo(null);
}
public static void main(String args[]) {
new TestMC().setVisible(true);
}
}