jtable 如何打印 用二维数组构建了一个jtable ,想用一个打印按扭来打印这个jtable里的记录,该怎么做呢? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 自己顶一下吧,在actionPerformed里输入下面代码即可实现.try { Toolkit kit = Toolkit.getDefaultToolkit(); //获取工具箱 Properties props = new Properties(); //props.put("awt.print.printer", "durango"); //设置打印属性 //props.put("awt.print.numCopies", "1"); props.setProperty("awt.print.printer","Epson5000"); props.setProperty("awt.print.numCopies","1"); if (kit != null) { //获取工具箱自带的打印对象 PrintJob printJob = kit.getPrintJob(this, "打印查询结果", props); if (printJob != null) { Graphics pg = printJob.getGraphics(); //获取打印对象的图形环境 if (pg != null) { try { jp1.printAll(pg); this.repaint(); }catch(Exception e) { } } } } }catch(Exception e) { } 看看我这个代码的问题好不?想在一个字符串中提取数字的........ java 中 类名.this 作用是什么?? 怎样设置JTextPane 帮忙看看这个expression该怎么分解 關於WindowAdapter--windowClosing的疑惑 求java读写XML的例子。谢谢。给分100。 j2ee, ejbいe穨 ぃ笵╯澈林穨Τぐ或闽玒 请指教:如何解决JAVA曲线动态更新? main中的参数可以随便写吗? 如何将int型转换为String型 请问如何在MySql内数据显示中文 格式化字符串的问题
try
{
Toolkit kit = Toolkit.getDefaultToolkit(); //获取工具箱
Properties props = new Properties();
//props.put("awt.print.printer", "durango"); //设置打印属性
//props.put("awt.print.numCopies", "1");
props.setProperty("awt.print.printer","Epson5000");
props.setProperty("awt.print.numCopies","1");
if (kit != null) {
//获取工具箱自带的打印对象
PrintJob printJob = kit.getPrintJob(this, "打印查询结果", props);
if (printJob != null) {
Graphics pg = printJob.getGraphics(); //获取打印对象的图形环境
if (pg != null)
{
try
{
jp1.printAll(pg);
this.repaint();
}catch(Exception e)
{
}
}
}
}
}catch(Exception e)
{
}