Reputation: 193
I have a GWT project. I am using a getWidget()
method on a horizontal panel and I want to know the type of widget returned by this method.
Whether the returned widget is a button or a textbox (as I would have put only these 2 kinds of widget into my horizontal panel initially).
For example:
HorizontalPanel x;
X.getWidget(4);
I want to know the type of the widget returned.
Is there any method for this?
Upvotes: 0
Views: 118
Reputation: 413
You can check the returned widget with instanceof
Example:
final Widget widget = horizontalPanel.getWidget(0);
if (widget instanceof Button) {
System.out.println("It's a button!");
} else if (widget instanceof TextBox) {
System.out.println("It's a textbox!");
}
Upvotes: 3