listbridge.java
来自「源码为科学出版社出版的英文<java设计模式>(影印版)所用的所有例」· Java 代码 · 共 40 行
JAVA
40 行
import java.awt.*;
import java.util.*;
import javax.swing.*;
//this is the Implementor class
//that decides which class to return
public class listBridge extends Bridger {
public static final int LIST=1, TABLE=2, TREE=3;
protected visList list;
public listBridge(int type) {
setLayout(new BorderLayout());
switch (type) {
case LIST:
list = new productList();
add("Center", (JComponent)list);
break;
case TABLE:
list = new productTable();
add("Center", (JComponent)list);
break;
case TREE:
list = new productTree();
add("Center", (JComponent)list);
break;
default:
list = null;
}
}
public void addData(Vector v) {
for(int i=0; i<v.size(); i++) {
String s = (String)v.elementAt (i);
list.addLine (s);
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?