Pergunta

How to show a calender for a Hotel Management System?

I need to make an application that allows the management of a Hotel, i would like to draw in the interface a calender which contains the dates and rooms, so the user can see which room is available for which date.

I use Java Swing, in Netbeans.

  calenderPanel.setLayout( new BorderLayout() );
  JXDatePicker date = new org.jdesktop.swingx.JXDatePicker(Locale.FRANCE);
  JXMonthView m = new JXMonthView();
  m.setFirstDayOfWeek(1);
  m.setDayForeground(6, Color.red);
  m.setDayForeground(5, Color.GREEN);

  Date fl = new Date(114, 0, 5);
  Date fl2 = new Date(114, 0, 6);

  Date[] tab = new Date[] {fl,fl2} ;

  m.setFlaggedDates(tab);
  m.setFlaggedDayForeground(Color.BLUE);

  calenderPanel.add(m, BorderLayout.CENTER);

  JPanel sud = new JPanel();
  calenderPanel.add(sud, BorderLayout.SOUTH);

The problem is that I can't show any other information in this calendar.

Foi útil?

Solução

I need to make an application that allows the management of a Hotel, i would like to draw in the interface a calender which contains the dates and rooms, so the user can see which room is available for which date.

JXDatePicker is intended to use as is, you cannot add any information in the calendar. But you can listen to selection changes and show available rooms in other components such as JList or JTable or even JComboBox.

Adding an ActionListener

JXDatePicker picker = new JXDatePicker();
picker.addActionListener(new ActionListener() {
    @Override
    public void actionPerformed(ActionEvent e) {
        // implementation here
    }
});

Adding a PropertyChangeListener

JXDatePicker picker = new JXDatePicker();
picker.addPropertyChangeListener("date", new PropertyChangeListener() {
    @Override
    public void propertyChange(PropertyChangeEvent e) {
        // implementation here
    }
});
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top