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;
}
延伸閱讀
文章來源于領測軟件測試網 http://www.kjueaiud.com/