本文整理汇总了Java中javax.swing.JTable.getPrintable方法的典型用法代码示例。如果您正苦于以下问题:Java JTable.getPrintable方法的具体用法?Java JTable.getPrintable怎么用?Java JTable.getPrintable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JTable
的用法示例。
在下文中一共展示了JTable.getPrintable方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: printWithJavaPrintDialog
import javax.swing.JTable; //导入方法依赖的package包/类
private static void printWithJavaPrintDialog() {
final JTable table = createAuthorTable(42);
Printable printable = table.getPrintable(
JTable.PrintMode.NORMAL,
new MessageFormat("Author Table"),
new MessageFormat("Page - {0}"));
PrinterJob job = PrinterJob.getPrinterJob();
job.setPrintable(printable);
boolean printAccepted = job.printDialog();
if (printAccepted) {
try {
job.print();
closeFrame();
} catch (PrinterException e) {
throw new RuntimeException(e);
}
}
}
示例2: printWithJavaPrintDialog
import javax.swing.JTable; //导入方法依赖的package包/类
private static void printWithJavaPrintDialog() {
final JTable table = createAuthorTable(50);
Printable printable = table.getPrintable(
JTable.PrintMode.NORMAL,
new MessageFormat("Author Table"),
new MessageFormat("Page - {0}"));
PrinterJob job = PrinterJob.getPrinterJob();
job.setPrintable(printable);
boolean printAccepted = job.printDialog();
if (printAccepted) {
try {
job.print();
closeFrame();
} catch (PrinterException e) {
throw new RuntimeException(e);
}
}
}
示例3: printDifferentRowHeight
import javax.swing.JTable; //导入方法依赖的package包/类
private static void printDifferentRowHeight() {
final JTable table = createAuthorTable(50);
table.setRowHeight(15, table.getRowHeight(15)+10);
Printable printable = table.getPrintable(
JTable.PrintMode.NORMAL,
new MessageFormat("Author Table"),
new MessageFormat("Page - {0}"));
PrinterJob job = PrinterJob.getPrinterJob();
job.setPrintable(printable);
boolean printAccepted = job.printDialog();
if (printAccepted) {
try {
job.print();
closeFrame();
} catch (PrinterException e) {
throw new RuntimeException(e);
}
}
}
示例4: printOneRowWithJavaPrintDialog
import javax.swing.JTable; //导入方法依赖的package包/类
private static void printOneRowWithJavaPrintDialog() {
final JTable table = createAuthorTable(1);
Printable printable = table.getPrintable(
JTable.PrintMode.NORMAL,
new MessageFormat("Author Table"),
new MessageFormat("Page - {0}"));
PrinterJob job = PrinterJob.getPrinterJob();
job.setPrintable(printable);
boolean printAccepted = job.printDialog();
if (printAccepted) {
try {
job.print();
closeFrame();
} catch (PrinterException e) {
throw new RuntimeException(e);
}
}
}
示例5: printWithCustomImageareaSize
import javax.swing.JTable; //导入方法依赖的package包/类
private static void printWithCustomImageareaSize() {
final JTable table = createAuthorTable(18);
PrintRequestAttributeSet printAttributes = new HashPrintRequestAttributeSet();
printAttributes.add(DialogTypeSelection.NATIVE);
printAttributes.add(new Copies(1));
printAttributes.add(new MediaPrintableArea(
0.25f, 0.25f, 8.0f, 5.0f, MediaPrintableArea.INCH));
Printable printable = table.getPrintable(
JTable.PrintMode.NORMAL,
new MessageFormat("Author Table"),
new MessageFormat("Page - {0}")
);
PrinterJob job = PrinterJob.getPrinterJob();
job.setPrintable(printable);
boolean printAccepted = job.printDialog(printAttributes);
if (printAccepted) {
try {
job.print(printAttributes);
closeFrame();
} catch (Exception e) {
throw new RuntimeException(e);
}
} else {
throw new RuntimeException("User cancels the printer job!");
}
}