JTable打印不打印页眉页脚
我正在尝试打印 JTable,并且希望每个站点上都有页眉和页脚。这是我的代码(当我单击应用程序中的打印按钮时调用它):
final MessageFormat headerFormat = new MessageFormat("My Custom Table Header");
final MessageFormat footerFormat = new MessageFormat("- {0} -");
try
{
this._table.print(PrintMode.FIT_WIDTH, headerFormat, footerFormat);
}
catch (final Exception pe)
{
//show message
}
return;
出现一个打印机对话框,我选择打印。如果表格包含大量数据,则该表格打印完美,甚至可以打印几页。但没有打印页眉或页脚。
有什么想法吗,我的代码有什么问题吗?
谢谢哈弗
布鲁斯
I'm trying to print a JTable and I want a header and footer on each site. Here is my code (it is called, when i click the print button in my app):
final MessageFormat headerFormat = new MessageFormat("My Custom Table Header");
final MessageFormat footerFormat = new MessageFormat("- {0} -");
try
{
this._table.print(PrintMode.FIT_WIDTH, headerFormat, footerFormat);
}
catch (final Exception pe)
{
//show message
}
return;
A printer dialog appears and i choose to print. The Table is printed perfectly, also over several pages, if it contains a lot of data. But there is no header or footer printed.
Any ideas, what's wrong with my code?
Thanks
Haferblues
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您的打印机/驱动程序很可能不支持页眉/页脚。我尝试使用上面的代码打印到 pdf 文件,效果很好。
Most likely your printer/driver does not support header/footers. I tried printing with above code to a pdf file and it works fine.
上面的代码工作得很好。这是打印机(或设置)不打印页眉/页脚。
Above code works just fine. it is the printer( or settings) which is not printing header/footers.