[英]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.