幣?
賠汽 15. output() 圭隈糞?
public static void output(Component c, PrintWriter pw, Outputter out) {
if ( out.isEnabled() ) {
out.begin(pw);
try {
outputWorker(0, new HashSet(), c, pw, out);
}
finally {
out.end(pw);
}
}
}
protected static void outputWorker(
int level, Set seen, Component c, PrintWriter pw, Outputter out) {
out.beginLevel(level, pw);
try {
if ( seen.add(c) ) { // only do the first time seen
// output self
out.beginObject(level, c, pw);
try {
out.identifyObject(level, c, pw);
out.recommendEol(level, pw);
out.outputComponent(level, c, pw);
if ( c instanceof Accessible ) {
out.recommendEol(level, pw);
out.outputAccessible(level, (Accessible)c, pw);
}
out.recommendEol(level, pw);
// output children (if any)
if ( c instanceof Container ) {
Component[] components =
((Container)c).getComponents();
if ( components.length == 0 ) {
out.emptyGroup(level, pw);
}
else {
out.beginGroup(level, pw);
for ( int i = 0;
i <
components.length; i++ ) {
out.separateGroupMembers(level, i, pw);
out.identifyGroupMember(level, i, pw);
Component xc = components[i];
if ( xc instanceof JComponent ) {
outputWorker(level + 1, seen,
(JComponent)xc, pw, out);
}
else {
out.outputObject(level, xc, pw);
}
}
out.endGroup(level, pw);
out.recommendEol(level, pw);
}
}
}
finally {
out.endObject(level, c, pw);
}
}
else {
out.outputObject(level, c, pw);
out.recommendEol(level, pw);
}
}
finally {
out.endLevel(level, pw);
}
}
为可访问性编码: 用JFC/Swing将可访问性构建到您的Java应用(12)
时间:2011-04-03 IBM Barry A. Feigenbaum
代码注释:
output 方法仅报告指定的组件(通常是 JFrame 、 JDialog 或 JPanel )。如果您 的应用程序由多个框架或对话框组成,则您需要为每个框架或对话框调用 output() 方法 ,以全面地了解应用程序的情况。
任何组件都可以被报告,但它应该是 JComponent 。通常使用顶级的组件 |