Exemplo n.º 1
0
 @Override
 public void actionPerformed(ActionEvent e) {
   if (e.getSource().equals(nyAvtaleKnapp)) {
     nyAvtale na;
     try {
       na = new nyAvtale(frame);
       na.pack();
       na.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
       na.setVisible(true);
     } catch (SQLException e1) {
       // TODO Auto-generated catch block
       e1.printStackTrace();
     }
   }
   if (e.getSource().equals(backButton)) {
     cal.set(Calendar.DAY_OF_WEEK, cal.getFirstDayOfWeek());
     cal.add(Calendar.DATE, -7);
     DateFormat df = new SimpleDateFormat("dd/MM/yyyy");
     Date firstDay = cal.getTime();
     String fDay = df.format(firstDay);
     String[] dates = fDay.split("/");
     int date = Integer.parseInt(dates[0]);
     int month = Integer.parseInt(dates[1]);
     int year = Integer.parseInt(dates[2]);
     try {
       generateThisWeek(date, month, year);
     } catch (SQLException e1) {
       // TODO Auto-generated catch block
       e1.printStackTrace();
     }
   }
   if (e.getSource().equals(nextButton)) {
     cal.set(Calendar.DAY_OF_WEEK, cal.getFirstDayOfWeek());
     cal.add(Calendar.DATE, 7);
     DateFormat df = new SimpleDateFormat("dd/MM/yyyy");
     Date firstDay = cal.getTime();
     String fDay = df.format(firstDay);
     String[] dates = fDay.split("/");
     int date = Integer.parseInt(dates[0]);
     int month = Integer.parseInt(dates[1]);
     int year = Integer.parseInt(dates[2]);
     try {
       generateThisWeek(date, month, year);
     } catch (SQLException e1) {
       // TODO Auto-generated catch block
       e1.printStackTrace();
     }
   }
   if (e.getSource().equals(egenKalender)) {
     frame.setKalenderEier(frame.getUser());
     setKalender();
     frame.enableComponents();
   }
 }
Exemplo n.º 2
0
 @Override
 public void itemStateChanged(ItemEvent e) {
   if (e.getSource().equals(kalendere)) {
     frame.setKalenderEier((Ansatt) kalendere.getSelectedItem());
     Ansatt ansatt = (Ansatt) kalendere.getSelectedItem();
     if (ansatt != null) {
       if (!frame.getUser().getNavn().equals(ansatt.getNavn())) {
         frame.disableComponents();
         this.backButton.setEnabled(true);
         this.nextButton.setEnabled(true);
         this.egenKalender.setEnabled(true);
         this.kalendere.setEnabled(true);
       } else {
         frame.enableComponents();
       }
     }
     setKalender();
   }
 }