• <bdo id='MA7OP'></bdo><ul id='MA7OP'></ul>
    <i id='MA7OP'><tr id='MA7OP'><dt id='MA7OP'><q id='MA7OP'><span id='MA7OP'><b id='MA7OP'><form id='MA7OP'><ins id='MA7OP'></ins><ul id='MA7OP'></ul><sub id='MA7OP'></sub></form><legend id='MA7OP'></legend><bdo id='MA7OP'><pre id='MA7OP'><center id='MA7OP'></center></pre></bdo></b><th id='MA7OP'></th></span></q></dt></tr></i><div id='MA7OP'><tfoot id='MA7OP'></tfoot><dl id='MA7OP'><fieldset id='MA7OP'></fieldset></dl></div>

        <small id='MA7OP'></small><noframes id='MA7OP'>

        <tfoot id='MA7OP'></tfoot>
      1. <legend id='MA7OP'><style id='MA7OP'><dir id='MA7OP'><q id='MA7OP'></q></dir></style></legend>

        获取 JTable 以打印表格格式

        时间:2023-06-28

          <tbody id='EmHrz'></tbody>

            <tfoot id='EmHrz'></tfoot>

            <small id='EmHrz'></small><noframes id='EmHrz'>

              <legend id='EmHrz'><style id='EmHrz'><dir id='EmHrz'><q id='EmHrz'></q></dir></style></legend>

                • <bdo id='EmHrz'></bdo><ul id='EmHrz'></ul>
                  <i id='EmHrz'><tr id='EmHrz'><dt id='EmHrz'><q id='EmHrz'><span id='EmHrz'><b id='EmHrz'><form id='EmHrz'><ins id='EmHrz'></ins><ul id='EmHrz'></ul><sub id='EmHrz'></sub></form><legend id='EmHrz'></legend><bdo id='EmHrz'><pre id='EmHrz'><center id='EmHrz'></center></pre></bdo></b><th id='EmHrz'></th></span></q></dt></tr></i><div id='EmHrz'><tfoot id='EmHrz'></tfoot><dl id='EmHrz'><fieldset id='EmHrz'></fieldset></dl></div>
                • 本文介绍了获取 JTable 以打印表格格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  所以我有一个标准的 JTable,我希望用户能够打印出来.我使用了 JTable.print(),它可以打印出表格的精确副本,但我希望它更多地采用表格格式,只有列名,然后是它们下面的数据,没有网格或任何东西.我以为这很简单,但我不知道该怎么做!有人做过吗?如果是这样,有人可以为我提供代码示例/示例吗?谢谢.

                  So I have a standard JTable and I want the user to be able to print it out. I used JTable.print() and that's fine for printing out an exact replica of the table, but I was hoping to have it more in a tabular format, with just the column names and then the data beneath them, no grids or anything. I thought this would be simple, but I have no clue what to do! Has anybody done this? If so, can someone provide me with code sample/example? Thank you.

                  推荐答案

                  你可以禁用网格线,例如...

                  You could disable the grid lines, for example...

                  JTable printTable = new JTable(table.getModel());
                  printTable.setSize(printTable.getPreferredSize());
                  JTableHeader tableHeader = printTable.getTableHeader();
                  tableHeader.setSize(tableHeader.getPreferredSize());
                  
                  printTable.setShowHorizontalLines(false);
                  printTable.setShowVerticalLines(false);
                  printTable.print(JTable.PrintMode.FIT_WIDTH);
                  

                  这使用一个临时的、屏幕外的 JTable 来进行实际打印,因此您需要确保配置任何所需的渲染器,但这个想法是合理的.

                  This uses a temporary, offscreen JTable to do the actually printing, so you will need to be sure to configure any required renderers, but the idea is sound.

                  此基本功能可确保屏幕上的 JTable 不会随着更改而更新,这可能会让用户感到害怕.

                  This basic ensures that the JTable that is on the screen doesn't get updated with the changed, which could be kind of freaking to users.

                  它还允许您根据需要更改 TableHeader ;)

                  It also allows you to change the TableHeader should you want to to ;)

                  这篇关于获取 JTable 以打印表格格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:如何用前导零写入csv? 下一篇:简单日期格式.返回错误日期的格式

                  相关文章

                  • <bdo id='K5t1N'></bdo><ul id='K5t1N'></ul>

                    <legend id='K5t1N'><style id='K5t1N'><dir id='K5t1N'><q id='K5t1N'></q></dir></style></legend>

                    <small id='K5t1N'></small><noframes id='K5t1N'>

                    <i id='K5t1N'><tr id='K5t1N'><dt id='K5t1N'><q id='K5t1N'><span id='K5t1N'><b id='K5t1N'><form id='K5t1N'><ins id='K5t1N'></ins><ul id='K5t1N'></ul><sub id='K5t1N'></sub></form><legend id='K5t1N'></legend><bdo id='K5t1N'><pre id='K5t1N'><center id='K5t1N'></center></pre></bdo></b><th id='K5t1N'></th></span></q></dt></tr></i><div id='K5t1N'><tfoot id='K5t1N'></tfoot><dl id='K5t1N'><fieldset id='K5t1N'></fieldset></dl></div>
                    1. <tfoot id='K5t1N'></tfoot>