繁体   English   中英

打印前预览JTextArea

[英]Preview a JTextArea before printing

在执行打印操作之前,如何在JDialog中提供JTextArea的预览? 打印对话框不提供此选项!

您可以使用TextComponentPrintable.getPrintable(textArea, null, null)并使用print()方法传递JPanel的Graphics来呈现打印视图。

还有针对JEditorPane的解决方案http://java-sl.com/JEditorPanePrinter.html

OP尚未完全指定此内容,但注释表明他/她希望用户在实际打印之前查看JTextArea中的内容。

您可以通过创建一个简单的JOptionPane来实现。

JOptionPane.showMessageDialog(frame,"your contents","your title",JOptionPane.PLAIN_MESSAGE);

如果这还不够,您可以通过创建一个类并扩展JDialog来创建自己的JDialog。

public class dialog extends JDialog{}

检出: http : //docs.oracle.com/javase/tutorial/uiswing/components/dialog.html

欲获得更多信息。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM