jTable Print Удаляет 40% выходных данных - PullRequest
0 голосов
/ 13 июля 2020
     SQLCONN.selectsql="SELECT Invoice_No,date,Customer_Name,GSTIN,State,Address,Item1,Qty1,Price1,Item2,Qty2,Price2,Item3,Qty3,Price3,Item4,Qty4,Price4,Item5,Qty5,Price5,Total_Price_WithoutGST,Total_WithGST FROM BillData WHERE month ='"+dt+"' AND year ='"+dt2+"'";
   MessageFormat header=new MessageFormat("Statement");
   MessageFormat footer=new MessageFormat("Statement End");
        try{
        SQLCONN.connect();
        if(SQLCONN.rs!=null){new StatementTable().setVisible(true);

            StatementTable.jTable1.setModel(DbUtils.resultSetToTableModel(SQLCONN.rs));
            TableColumn column = null;
       for (int i = 0; i < 22; i++) {
        column = jTable1.getColumnModel().getColumn(i);
        if (i==2||i==3||i==4||i==6) {
            column.setPreferredWidth(150);
        }
         else {
            column.setPreferredWidth(90);
        }}
for (int colIdx = 0; colIdx < jTable1.getColumnCount(); colIdx++) {
    for (int rowIdx = 0; rowIdx < jTable1.getRowCount(); rowIdx++) {
        TableCellRenderer renderer = jTable1.getCellRenderer(rowIdx, colIdx);
        Object cellValue = jTable1.getValueAt(rowIdx, colIdx);
        renderer.getTableCellRendererComponent(jTable1, cellValue,true, true, rowIdx, colIdx);
    }
}       
PrintRequestAttributeSet set = new HashPrintRequestAttributeSet();
set.add(OrientationRequested.PORTRAIT);
StatementTable.jTable1.print(JTable.PrintMode.FIT_WIDTH, header, footer, true,set, true);
        }

Я новичок ie в java ... Jtable Есть от 21 до 22 столбцов .. Проблема возникает после изменения ширины столбца. Мне нужен полный jTable для печати

...