http://expert.csdn.net/Expert/topic/1186/1186146.xml?temp=.7482569
解决方案 »
- 如何忽略BufferedReader的readLine()读到的中间多个空格
- 如何根据一个svn地址在eclipse中设置
- 如何把数据库中查到的数据写到JTABLE中
- 递归方法
- 编写一个类,包括一个字符串变量,在定义处将期初始化.另一个字符串变量由构建器初始化.说明这两种方法的区别?
- 关于GUI的程序问题,希望得到大家的帮助
- 读取文件哪里出错了
- 一直在想一个菜鸟问题:java没了指针用什么来代替??
- AppletViewer执行.html没问题,想用IE直接打开时 为什么需要javac -target 1.1?!
- 在程序主体面板中如何设置多个工具栏?
- 关于java连接SqlServer的问题!
- 菜鸟的问题
import java.applet.Applet;
import java.awt.*;
import java.awt.event.*;
import java.util.Properties;public class PrintApplet extends Applet {
Button printButton = new Button("print ..."); static Frame getFrame(Component c) {
while((c = c.getParent()) != null) {
if(c instanceof Frame)
return (Frame)c;
}
return null;
}
static void printComponents(Component c) {
Toolkit tk = Toolkit.getDefaultToolkit();
Frame frame = getFrame(c);
Properties props = new Properties(); props.put("awt.print.printer", "durango");
props.put("awt.print.numCopies", "2"); if(tk != null) {
String name = c.getName() + " print job";
PrintJob pj = tk.getPrintJob(frame, name, props); if(pj != null) {
Graphics pg = pj.getGraphics(); if(pg != null) {
try {
c.printAll(pg);
}
finally {
pg.dispose();
}
}
pj.end();
}
System.out.println(props);
}
}
public void init() {
add(printButton);
add(new Label("print this label"));
add(new TextField("print this textfield"));
add(new TextArea(10,20)); printButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
printComponents(PrintApplet.this);
}
});
}
}
能不能帮我说不说最后打印出来的效果,
如果我输入的是一个JScrolPane(JTable),它能自动把所有的表格都打出来吗?包括不可见的,以及能不能自动换行,如果长度过长的话