⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.java

📁 日历记事本
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
            }
        });

        spnYear.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                spnYearStateChanged(evt);
            }
        });

        jLabel1.setText("\u5e74:");

        jLabel2.setText("\u6708:");

        jScrollPane1.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jScrollPane1MouseClicked(evt);
            }
        });

        daysTable.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null}
            },
            new String [] {
                "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"
            }
        ));
        daysTable.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                daysTableMouseClicked(evt);
            }
        });

        jScrollPane1.setViewportView(daysTable);

        jButton1.setText("\u5220\u9664\u8fc7\u671f\u5b89\u6392");
        jButton1.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jButton1MouseClicked(evt);
            }
        });

        txtN.setText("jTextField1");

        jLabel3.setText("\u4eca\u65e5\u5b89\u6392:");

        bir.setBackground(new java.awt.Color(55, 153, 255));
        bir.setForeground(new java.awt.Color(255, 102, 102));
        bir.setText("\u751f\u65e5");

        met.setText("\u4f1a\u8bae");

        game.setText("\u5a31\u4e50");

        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                .addContainerGap()
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(layout.createSequentialGroup()
                        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                            .add(jScrollPane1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                            .add(layout.createSequentialGroup()
                                .add(jLabel1)
                                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                                .add(spnYear, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 77, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                .add(33, 33, 33)
                                .add(jLabel2)
                                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                                .add(cmbMonth, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 76, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 117, Short.MAX_VALUE)
                                .add(jButton1))
                            .add(layout.createSequentialGroup()
                                .add(bir)
                                .add(23, 23, 23)
                                .add(met)
                                .add(27, 27, 27)
                                .add(game))
                            .add(jLabel3))
                        .addContainerGap())
                    .add(layout.createSequentialGroup()
                        .add(txtN, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 442, Short.MAX_VALUE)
                        .add(20, 20, 20))))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                .addContainerGap()
                .add(jScrollPane1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 120, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jLabel1)
                    .add(jLabel2)
                    .add(cmbMonth, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(spnYear, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(jButton1))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jLabel3)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(txtN, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 109, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .add(15, 15, 15)
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(bir)
                    .add(met)
                    .add(game))
                .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jButton1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton1MouseClicked
// TODO add your handling code here:
        JTable t=daysTable;
        String d=(t.getValueAt(t.getSelectedRow(),t.getSelectedColumn())).toString();
        d=(spnYear.getValue()).toString()+"_"+Integer.toString(cmbMonth.getSelectedIndex()+1)+"_"+d;
        
        Enumeration e=ht.keys();
        while(e.hasMoreElements()) {
            String s=(String)e.nextElement();
            
            if(s.compareTo(d)<0) {
                ht.remove(s);
            }
        }
        
        updateView();
    }//GEN-LAST:event_jButton1MouseClicked

    private void spnYearStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_spnYearStateChanged
// TODO add your handling code here:
        int day = calendar.get(Calendar.DAY_OF_MONTH);
        calendar.set(Calendar.DAY_OF_MONTH, 1);
        calendar.set(Calendar.YEAR, ((Integer) spnYear.getValue()).intValue());
        int maxDay = calendar.getActualMaximum(Calendar.DAY_OF_MONTH);
        calendar.set(Calendar.DAY_OF_MONTH, day > maxDay ? maxDay : day);
        updateView(); 
    }//GEN-LAST:event_spnYearStateChanged

    private void cmbMonthActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmbMonthActionPerformed
// TODO add your handling code here:
        int day = calendar.get(Calendar.DAY_OF_MONTH);
        calendar.set(Calendar.DAY_OF_MONTH, 1);
        calendar.set(Calendar.MONTH, cmbMonth.getSelectedIndex());
        int maxDay = calendar.getActualMaximum(Calendar.DAY_OF_MONTH);
        calendar.set(Calendar.DAY_OF_MONTH, day > maxDay ? maxDay : day);
        updateView(); 
    }//GEN-LAST:event_cmbMonthActionPerformed

    private void cmbMonthPropertyChange(java.beans.PropertyChangeEvent evt) {//GEN-FIRST:event_cmbMonthPropertyChange
// TODO add your handling code here:
    }//GEN-LAST:event_cmbMonthPropertyChange

    private void formWindowClosing(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosing
// TODO add your handling code here:
        try {
            Fout=new FileOutputStream(a);
            Oout=new ObjectOutputStream(Fout);
        }
        catch(Exception e) {}
        
        try {
            Oout.writeObject(ht);
            Fout.close();
        }
        catch(IOException e) {}
    }//GEN-LAST:event_formWindowClosing

    private void daysTableMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_daysTableMouseClicked
// TODO add your handling code here:
        JTable t=((JTable)(evt.getSource()));
        String d=(t.getValueAt(t.getSelectedRow(),t.getSelectedColumn())).toString();
        note.noteShow((spnYear.getValue()).toString()+"_"+Integer.toString(cmbMonth.getSelectedIndex()+1)+"_"+d);
    }//GEN-LAST:event_daysTableMouseClicked

    private void jScrollPane1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jScrollPane1MouseClicked
// TODO add your handling code here:
    }//GEN-LAST:event_jScrollPane1MouseClicked
    
    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new Main().setVisible(true);
            }
        });
    }
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel bir;
    private javax.swing.JComboBox cmbMonth;
    private javax.swing.JTable daysTable;
    private javax.swing.JLabel game;
    private javax.swing.JButton jButton1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JLabel met;
    private javax.swing.JSpinner spnYear;
    private javax.swing.JTextField txtN;
    // End of variables declaration//GEN-END:variables
    
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -