public interface Component {
public Component at(int x, int y, int width, int height);
public Component in(Container);
……
}
Button 的实现如下:
public class Button implements Component{
public JButton btn = new JButton();
public Component title(String t){
btn.setText(t);
return this;
}
public Component at(int x, int y, int width, int height) {
Rectangle rect = new Rectangle(x,y,width,height);
btn.setBounds(rect);
return this;
}
延伸阅读
文章来源于领测软件测试网 https://www.ltesting.net/