Hi all,
I'm using a lot of anonymous class code like this in order to keep my code more readable (Java 1.6, SmartGWT 2.5, Eclipse Indigo)
I'd like to do the same with handlers, eg this handler:
where checkWholeDate a method and timeItem, blurbItem other final widgets.
I can't do it like this:
because the "dateChooser" method parameter is not available in the inner handler anonymous class.
Do you have an idea how I could also move the handler to the widget anonymous class?
Thanks,
Blama
I'm using a lot of anonymous class code like this in order to keep my code more readable (Java 1.6, SmartGWT 2.5, Eclipse Indigo)
Code:
final DateChooser dateChooser = new DateChooser() { { Calendar today = Calendar.getInstance(); setStartYear(today.get(Calendar.YEAR) - 1); setEndYear(today.get(Calendar.YEAR) + 1); setFirstDayOfWeek(1); setWidth(100); setTodayButtonTitle("Heute"); } };
Code:
dateChooser.addDataChangedHandler(new DataChangedHandler() { @Override public void onDataChanged(DataChangedEvent event) { checkWholeDate(dateChooser, timeItem, blurbItem); } });
I can't do it like this:
Code:
final DateChooser dateChooser = new DateChooser() { { Calendar today = Calendar.getInstance(); setStartYear(today.get(Calendar.YEAR) - 1); setEndYear(today.get(Calendar.YEAR) + 1); setFirstDayOfWeek(1); setWidth(100); setTodayButtonTitle("Heute"); addDataChangedHandler(new DataChangedHandler() { @Override public void onDataChanged(DataChangedEvent event) { checkWholeDate(dateChooser, timeItem, blurbItem); } }); } };
Do you have an idea how I could also move the handler to the widget anonymous class?
Thanks,
Blama