利用java语言开发建议日历记事本程序。 public class CalendarPad extends JFrame implements MouseListener{ int year,month,day; Hashtable hashtable; File file; static JTextField showDay[]; JLabel title[]; Calendar calendar; int week; NotePad notepad=null; Month changemonth; Year changeyear; String 星期[]={"日","一","二","三","四","五","六"}; JPanel leftPanel,rightPanel; //以下是定义CalendarPad方法 public CalendarPad(int year,int month,int day) { super("Duang日历记事本"); //设置窗体标题 leftPanel=new JPanel(); JPanel leftCenter=new JPanel(); JPanel leftNorth=new JPanel(); leftCenter.setLayout(new GridLayout(7,7)); rightPanel=new JPanel(); this.year=year; this.month=month; this.day=day; changeyear=new Year(this); changeyear.setYear(year); changemonth=new Month(this); changemonth.setMonth(month); title=new JLabel[7]; //定义显示星期标签 showDay=new JTextField[42]; for(int j=0;j<7;j++) { title[j]=new JLabel(); title[j].setText(星期[j]); //定义显示星期标签 title[j].setBorder(BorderFactory.createRaisedBevelBorder()); //定义边框为斜面边框(凸) leftCenter.add(title[j]); //显示星期标签 } title[0].setForeground(Color.red); //将周日显示为红色 title[6].setForeground(Color.red); //将周六显示为红色 for(int i=0;i<42;i++) { showDay[i]=new JTextField(); showDay[i].addMouseListener(this); //添加鼠标进入 showDay[i].setEditable(false); //设置为不可编辑标签 leftCenter.add(showDay[i]); } calendar=Calendar.getInstance(); Box box=Box.createHorizontalBox(); box.add(changeyear); //添加改变年控件 box.add(changemonth); //添加改变月控件 leftNorth.add(box); //定位改变年月标签 leftPanel.setLayout(new BorderLayout()); leftPanel.add(leftNorth,BorderLayout.NORTH); leftPanel.add(leftCenter,BorderLayout.CENTER); leftPanel.add(new Label(""), BorderLayout.SOUTH) ; leftPanel.validate(); Container con=getContentPane(); JSplitPane split=new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, leftPanel,rightPanel); con.add(split,BorderLayout.CENTER); con.validate(); hashtable=new Hashtable(); file=new File("日历记事本.txt"); //新建"日历记事本.txt"文件 if(!file.exists()) //判断文件是否存在 { try{ FileOutputStream out=new FileOutputStream(file); ObjectOutputStream objectOut=new ObjectOutputStream(out); objectOut.writeObject(hashtable); objectOut.close(); out.close(); } catch(IOException e) { } } notepad=new NotePad(this); rightPanel.add(notepad); set_calendar(year,month); addWindowListener(new WindowAdapter() //注册监听器 { public void windowClosing(WindowEvent e) { System.exit(0); } }); setVisible(true); //设置主面板可见 setBounds(500,100,600,285); //设置主面板大小及位置 validate(); }



















- 粉丝: 63
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助


最新资源
- 如何借助AI+数智应用工具提升科技平台的服务效率?.docx
- 如何借助AI+数智应用快速生成高质量的科技活动策划方案?.docx
- 如何借助AI+数智应用破解科技管理系统“缺乏价值创造”的难题?.docx
- 如何借助AI+数智应用手段激活科技管理系统的内外部资源?.docx
- 如何借助AI+数智应用提升大学科技管理的效能与价值?.docx
- 如何借助AI+数智应用有效构建科技资源平台以解决资源丰富性问题?.docx
- 如何利用AI+数智应用技术提升科技管理工作的价值创造能力?.docx
- 如何利用AI+数智应用技术提升科技管理工作的效率和创新能力?.docx
- 如何利用AI+数智应用让单场科技活动产生长期效益?.docx
- 如何利用AI+数智应用全流程创新诊断快速提升科技管理系统的智能化水平?.docx
- 如何利用AI+数智应用让科技管理工作既高效又具备创新性?.docx
- 如何利用AI+数智应用新产品提升政府科技监测的价值创造能力?.docx
- 如何让技术供需对接活动的匹配通过AI+数智应用更精准,避免资源浪费?.docx
- 如何通过AI+数智应用服务提升科技活动组织效率和资源匹配精准度?.docx
- 如何通过AI+数智应用工具解决科技管理中的环节性痛点?.docx
- 如何通过AI+数智应用工具提升科技活动供需匹配效率?.docx


