資源簡介
日程管理。自己參考寫的一個。功能不是很完善,歡迎交流,一起學習改進。
代碼片段和文件信息
/*Codeing?By?Jockey?Wu
??參考做的一個*/
import?java.io.*;//引入相關物件
import?java.util.*;
import?java.lang.Thread;
import?java.awt.BorderLayout;
import?java.awt.event.ActionEvent;
import?java.awt.event.ActionListener;
import?javax.swing.BorderFactory;
import?javax.swing.ComboBoxModel;
import?javax.swing.DefaultComboBoxModel;
import?javax.swing.JButton;
import?javax.swing.JComboBox;
import?javax.swing.JDesktopPane;
import?javax.swing.JLabel;
import?javax.swing.JTextArea;
import?javax.swing.JTextField;
import?javax.swing.JScrollPane;
import?javax.swing.WindowConstants;
import?javax.swing.border.BevelBorder;
import?javax.swing.border.LineBorder;
import?javax.swing.border.SoftBevelBorder;
?
public?class?NewJframe?extends?javax.swing.Jframe?//建立一視窗物件
{
??private?JDesktopPane?jDesktopPane1;//相關物件宣告
??private?JDesktopPane?jDesktopPane2;
??private?JButton?jButton1;
??private?JButton?jButton2;
??private?JLabel?jLabel2;
??private?JLabel?jLabel4;
??private?JLabel?jLabel3;
??private?JLabel?jLabel5;
??private?JLabel?jLabel6;
??private?JLabel?jLabel7;
??private?JLabel?jLabel8;
??private?JComboBox?jComboBox1;
??private?JTextField?jTextField1;
??private?JButton?jButton3;
??private?JTextArea?jTextArea1;
??private?JLabel?jLabel1;
?
??public?static?void?main(String[]?args)?throws?IOException//主程式開始
??{
????NewJframe?inst?=?new?NewJframe();
????inst.setVisible(true);
??}//主程式結束
??
??public?NewJframe()//建立視窗開始
??{
????super();
????initGUI();//呼叫GUI函數
??}//建立視窗結束
??
??public?int[]?getdate()//取得系統日期函數開始
??{
????int[]?date_array?=?new?int[3];
????Calendar?ca?=?new?GregorianCalendar();??
????date_array[0]?=?ca.get(Calendar.YEAR);//年
????date_array[1]?=?ca.get(Calendar.MONTH)+1;//月
????date_array[2]?=?ca.get(Calendar.DAY_OF_MONTH);//日
????return?date_array;//回傳自訂日期陣列
??}//取得系統日期函數結束
?
??public?void?new_btn()//重新產生日期按鈕函數開始
??{
????jTextArea1.setText(““);//清空記事
????int?yearmonth;
????year?=?Integer.parseInt(jLabel5.getText().substring(04));//設定為已選擇的年
????month?=?Integer.parseInt(jLabel5.getText().substring(79));//設定為已選擇的月
????date_btn_create(yearmonth);//呼叫產生日期按鈕函數
??}//重新產生日期按鈕函數結束
??
??public?void?date_btn_create(int?yearint?month)//產生日期按鈕
??{
????int?y=0x=0x_add=0y_add=0week_add=0date_acc=0week_of_day=0;
????String?syearsmonthsdayfilename;
????syear?=?String.valueOf(year);
????smonth?=?String.valueOf(month);
????if?(smonth.length()?==?1)//若小於10月(一位數)就在前面加0
??????smonth?=?“0“+smonth;
????
????jDesktopPane1.remove(jDesktopPane2);//移除桌面2(日期按鈕附著,也就是把日期按鈕移除)
????jDesktopPane2?=?new?JDesktopPane();//產生一個新的桌面
????jDesktopPane1.add(jDesktopPane2);
????jDesktopPane2.setBounds(0?30?252?196);//設定大小及位置
????jDesktopPane2.setBackground(new?java.awt.Color(148205176));//設定顏色
??????
????switch(month)//設定月份天數
????{
??????case?1://大月31天
??????case?3:
??????case?5:
??????case?7:
??????case?8:
??????case?10:
??????case?12:
????????date_acc?=?31;
????????break;
????????
??????case?4://
評論
共有 條評論