0

Is there any way to get type of GWT widget?

for(Widget w : widgetList)  
{  
 //if w is textbox type, read value and do something

}
Rahul
  • 3
  • 4
  • 1
    `w instanceof TextBox`? Or possibly `w.getClass() == TextBox.class`? – Colin Alworth Oct 23 '12 at 13:27
  • Of course. Type of GWT Widget is just a class. And a class is also object - instance of the class [Class](http://docs.oracle.com/javase/7/docs/api/java/lang/Class.html). But the way therefore, more correctly to use the method [equals](http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html#equals(java.lang.Object)): `w.getClass().equals(TextBox.class)`. [Read more](http://stackoverflow.com/questions/4989818/instanceof-vs-getclass/4989835#4989835) – kapandron Oct 23 '12 at 15:23

1 Answers1

2
for(Widget w : widgetList)
{
  if(w instanceof textbox)
        // read value and do something
}
Martin
  • 584
  • 3
  • 12