jdk/src/java.desktop/share/classes/javax/swing/TablePrintable.java
changeset 43077 785bbcd9812a
parent 34397 86a74cb6c903
equal deleted inserted replaced
43076:a2d90fcf0a70 43077:785bbcd9812a
   378         }
   378         }
   379 
   379 
   380         // print the current section of the table
   380         // print the current section of the table
   381         g2d.translate(-clip.x, -clip.y);
   381         g2d.translate(-clip.x, -clip.y);
   382         g2d.clip(clip);
   382         g2d.clip(clip);
       
   383 
       
   384         // set a property so that BasicTableUI#paint can know JTable printMode
       
   385         // is FIT_WIDTH since TablePrintable.printMode is not accessible from BasicTableUI
       
   386         if (printMode == JTable.PrintMode.FIT_WIDTH) {
       
   387             table.putClientProperty("Table.printMode", JTable.PrintMode.FIT_WIDTH);
       
   388         }
   383         table.print(g2d);
   389         table.print(g2d);
   384 
   390 
   385         // restore the original transform and clip
   391         // restore the original transform and clip
   386         g2d.setTransform(oldTrans);
   392         g2d.setTransform(oldTrans);
   387         g2d.setClip(oldClip);
   393         g2d.setClip(oldClip);
   405         }
   411         }
   406         int rowHeight = 0;
   412         int rowHeight = 0;
   407         for(int visrow = rMin; visrow < rMax; visrow++) {
   413         for(int visrow = rMin; visrow < rMax; visrow++) {
   408             rowHeight += table.getRowHeight(visrow);
   414             rowHeight += table.getRowHeight(visrow);
   409         }
   415         }
   410         g2d.drawRect(0, 0, visibleBounds.width, hclip.height + rowHeight);
   416         // If PrintMode is FIT_WIDTH, then draw rect for entire column width while
   411 
   417         // printing irrespective of how many columns are visible in console
       
   418         if (printMode == JTable.PrintMode.FIT_WIDTH) {
       
   419             g2d.drawRect(0, 0, clip.width, hclip.height + rowHeight);
       
   420         } else {
       
   421             g2d.drawRect(0, 0, visibleBounds.width, hclip.height + rowHeight);
       
   422         }
       
   423 
       
   424         // clear the property
       
   425         if (printMode == JTable.PrintMode.FIT_WIDTH) {
       
   426             table.putClientProperty("Table.printMode", null);
       
   427         }
   412         // dispose the graphics copy
   428         // dispose the graphics copy
   413         g2d.dispose();
   429         g2d.dispose();
   414 
   430 
   415         return PAGE_EXISTS;
   431         return PAGE_EXISTS;
   416     }
   432     }
   532 
   548 
   533             colWidth = colModel.getColumn(col).getWidth();
   549             colWidth = colModel.getColumn(col).getWidth();
   534         } while (clip.width + colWidth <= pw);
   550         } while (clip.width + colWidth <= pw);
   535 
   551 
   536     }
   552     }
   537 
       
   538 }
   553 }