WEB开发网
开发学院软件开发Java 建立一个 Derby 日历,第 2 部分: 嵌入选项(下)... 阅读

建立一个 Derby 日历,第 2 部分: 嵌入选项(下)

 2010-04-19 00:00:00 来源:WEB开发网   
核心提示: 使用用户信息进行连接这意味着如果需要保存、显示事件和发送提示,必须检索用户名和口令信息并一起传递,建立一个 Derby 日历,第 2 部分: 嵌入选项(下)(3),如 清单 17 所示,清单 17. 使用登录信息进行连接 ...classSaveListenerimplementsjava.aw

使用用户信息进行连接

这意味着如果需要保存、显示事件和发送提示,必须检索用户名和口令信息并一起传递,如 清单 17 所示。

清单 17. 使用登录信息进行连接

   ... 
 class SaveListener implements java.awt.event.ActionListener 
 { 
   public void actionPerformed(java.awt.event.ActionEvent e) { 
     int month = newMonthCombo.getSelectedIndex() + 1; 
     int day = newDayCombo.getSelectedIndex() + 1; 
     int year = Integer.parseInt( 
            newYearCombo.getSelectedItem().toString()); 
     String newTitle = titleBox.getText(); 
     String newDescription = descriptionBox.getText(); 
     String newReminders = reminderBox.getText(); 
 
     JButton button = (JButton)e.getSource(); 
     CalendarFrame window = 
           (CalendarFrame)button.getTopLevelAncestor(); 
 
     EventClass theNewEvent = null; 
     theNewEvent = new EventClass(newTitle, newDescription, newReminders, 
                  month, day, year, window.username, 
                  window.password); 
 
   } 
 } 
 
 class ShowListener implements java.awt.event.ActionListener 
 { 
   public void actionPerformed(java.awt.event.ActionEvent e) 
   { 
     int month = showMonthCombo.getSelectedIndex()+1; 
     int day = showDayCombo.getSelectedIndex()+1; 
     int year = Integer.parseInt( 
          showYearCombo.getSelectedItem().toString()); 
 
     JButton button = (JButton)e.getSource(); 
     CalendarFrame window = 
           (CalendarFrame)button.getTopLevelAncestor(); 
 
     EventClass[] eventsToShow = Calendar.getEvents(month, day, 
             year, window.username, window.password); 
     String textToShow = null; 
 
     if (eventsToShow == null){ 
      textToShow = "Nothing for that date."; 
     } else { 
      textToShow = "There are "+eventsToShow.length+ 
                  " events for this date:\n\n"; 
      for (int i=0; i<eventsToShow.length; i++){ 
        String thisEventText = eventsToShow[i].getTitle() + "\n" + 
           eventsToShow[i].getDescription() + "\nReminders to: "+ 
           eventsToShow[i].getRemindersTo() + "\n"; 
        textToShow = textToShow + thisEventText; 
      } 
     } 
 
     monthToShow.setText(new String().valueOf(month)); 
     dayToShow.setText(new String().valueOf(day)); 
     yearToShow.setText(new String().valueOf(year)); 
     events.setText(textToShow); 
   } 
 } 
 
 class RemindListener implements java.awt.event.ActionListener 
 { 
   public void actionPerformed(java.awt.event.ActionEvent e) 
   { 
 
     ShowListener showListener= new ShowListener(); 
     showListener.actionPerformed(e); 
 
     int month = showMonthCombo.getSelectedIndex()+1; 
     int day = showDayCombo.getSelectedIndex()+1; 
     int year = Integer.parseInt( 
             showYearCombo.getSelectedItem().toString()); 
 
     JButton button = (JButton)e.getSource(); 
     CalendarFrame window = 
           (CalendarFrame)button.getTopLevelAncestor(); 
 
     Reminder reminder = new Reminder(); 
     reminder.sendAllReminders(month, day, year, 
                window.username, window.password); 
 
   } 
 } 
...

上一页  1 2 3 4 5 6 7 8  下一页

Tags:建立 一个 Derby

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接