You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It seems to me the component looks nicer if it tracks the mouse movements and is easy to support.
CalendarGridPanel constructor:
- // addMouseListener(this);
+ addMouseListener(new MouseAdapter() {
+ public void mouseEntered(MouseEvent e) {
+ requestFocusInWindow();
+ }
+ });
public void mouseEntered(MouseEvent e) {
+ Component c = e.getComponent();
+ if (c instanceof DateLabel) {
+ try {
+ int day = Integer.parseInt(((DateLabel) c).getText());
+ Calendar cal = Calendar.getInstance();
+ cal.setTime(focusDate);
+ cal.set(Calendar.DAY_OF_MONTH, day);
+ focusDate = cal.getTime();
+ reflectData();
+ } catch (NumberFormatException ex) {}
+ }
}
The mouseEntered above does the job, but probably there's a simpler version that reads the focusDate directly from DateLabel. Unfortunately, this didn't work for me and I ran out of time do to further exploration. The basic idea would be something like:
// !!!The following impl. does not work because DateLabel.getDate() always returns null !!!
public void mouseEntered(MouseEvent e) {
Component c = e.getComponent();
if (c instanceof DateLabel) {
requestFocusInWindow();
Date d = ((DateLabel) c).getDate();
if (d != null) {
focusDate = d;
reflectData();
}
}
}
The text was updated successfully, but these errors were encountered:
It seems to me the component looks nicer if it tracks the mouse movements and is easy to support.
CalendarGridPanel constructor:
The mouseEntered above does the job, but probably there's a simpler version that reads the focusDate directly from DateLabel. Unfortunately, this didn't work for me and I ran out of time do to further exploration. The basic idea would be something like:
// !!!The following impl. does not work because DateLabel.getDate() always returns null !!!
The text was updated successfully, but these errors were encountered: