Reputation: 3
I wanted to know is it possible to loop through all buttons in multiple files?
For example, let's say i have a few classes:
Class1.java
Button btn1 = New Button("BUTTON");
Button btn2 = New Button("BUTTON");
Class2.java
Button btn3 = New Button("BUTTON");
I guess one way how to change each button's style would be like this:
btn1.addStyleName("button");
btn2.addStyleName("button");
btn3.addStyleName("button");
But i want to change specific button colors without using addStyleName. The reason is - i have a lot of buttons that have the same caption. Any ideas?
Upvotes: 0
Views: 174
Reputation: 3356
Create your own button class:
class MyButton extends Button {
public MyButton() {
super();
setCaption("BUTTON");
addStyleName("button");
}
}
Upvotes: 3
Reputation: 31
I think your need is a kind of Util class which will return the button objects with same class name. And call this Util method wherever you need.
eg.
public static Button createButton{
Button button = new Button();
button.addStyleName("button");
return button;
}
Upvotes: 3