繁体   English   中英

仅打印带有徽标的JTable填充数据

[英]printing only filled data from JTable with logo

我的程序有一个带有100个空白行的JTable。 让用户只填充10行。 现在,他只想打印顶部带有徽标的填充行。 怎么做 ?

这是我使用的代码:

if(e.getSource() == print){
    try {
        table.print(JTable.PrintMode.FIT_WIDTH, head, null); 
    } catch (java.awt.print.PrinterException e1) {
         System.err.format("Cannot print %s%n", e1.getMessage()); 
    }
}

它只打印所有100行。

我想只打印已填充的行(让前10行填充)

您可以在打印前过滤空行:

table.setAutoCreateRowSorter(true);
RowFilter filter = new RowFilter() {

    public void include(Entry entry) {
        // here add a loop which checks if 
        // any of the values in the entry is not-null
        // return true if yes, false otherwise (that is all empty)
    }
};
((DefaultRowSorter) table.getRowSorter()).setRowFilter(filter);
table.print(....);

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM