参考书籍完成的一个可以打印一个单独JTable组件的涵数,希望对大家有所帮助.
private void printTable() {
Toolkit kit = Toolkit.getDefaultToolkit(); //获取工具箱
Properties props = new Properties();
props.put("awt.print.printer", "durango"); //设置打印属性
props.put("awt.print.numCopies", "2");
if (kit != null) {
//获取工具箱自带的打印对象
PrintJob printJob = kit.getPrintJob(this, "打印 页面", props);
if (printJob != null) {
Graphics pg = printJob.getGraphics(); //获取打印对象的图形环境
Graphics2D g2 = (Graphics2D) pg; ///[ 查看全文 ]