當前位置: 首頁>>代碼示例>>Java>>正文


Java Book類代碼示例

本文整理匯總了Java中java.awt.print.Book的典型用法代碼示例。如果您正苦於以下問題:Java Book類的具體用法?Java Book怎麽用?Java Book使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Book類屬於java.awt.print包,在下文中一共展示了Book類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: print

import java.awt.print.Book; //導入依賴的package包/類
/**
 * Constructs a new PrinterJob, allows the user to select which printer to
 * print to, And then prints the node.
 */
public void print() {
    final PrinterJob printJob = PrinterJob.getPrinterJob();
    final PageFormat pageFormat = printJob.defaultPage();
    final Book book = new Book();
    book.append(this, pageFormat);
    printJob.setPageable(book);

    if (printJob.printDialog()) {
        try {
            printJob.print();
        }
        catch (final PrinterException e) {
            throw new RuntimeException("Error Printing", e);
        }
    }
}
 
開發者ID:mleoking,項目名稱:PhET,代碼行數:21,代碼來源:PNode.java

示例2: initialize

import java.awt.print.Book; //導入依賴的package包/類
private void initialize(byte[] pdfContent, String jobName,String nomeImpressora) throws IOException, PrinterException {
    ByteBuffer bb = ByteBuffer.wrap(pdfContent);

    PDFFile pdfFile = new PDFFile(bb);
    PDFPrintPage pages = new PDFPrintPage(pdfFile);

    PrintService[] pservices = PrinterJob.lookupPrintServices();

    System.out.println(pservices.length);
    if (pservices.length > 0) {
        for (PrintService ps : pservices) {
            System.out.println("Impressora Encontrada: " + ps.getName());

            if (ps.getName().contains(nomeImpressora)) {
                System.out.println("Impressora Selecionada: " + nomeImpressora);
                impressora = ps;
                break;
            }
        }
    }
    if (impressora != null) {
        pjob = PrinterJob.getPrinterJob();
        pjob.setPrintService(impressora);

        PageFormat pf = PrinterJob.getPrinterJob().defaultPage();

        pjob.setJobName(jobName);
        Book book = new Book();
        book.append(pages, pf, pdfFile.getNumPages());
        pjob.setPageable(book);

      
        Paper paper = new Paper();
        paper.setSize(getWidth, getHeight);
        paper.setImageableArea(margin, (int) margin / 4, getWidth - margin * 2, getHeight - margin * 2);
        //paper.setImageableArea(margin,margin, paper.getWidth()-margin*2,paper.getHeight()-margin*2);
        pf.setOrientation(orientacao);
        pf.setPaper(paper);
    }
}
 
開發者ID:JIGAsoftSTP,項目名稱:NICON,代碼行數:41,代碼來源:PrintPdf.java

示例3: doPrint

import java.awt.print.Book; //導入依賴的package包/類
/**
 * Print the current document.
 */
public void doPrint() {
    PrinterJob pjob = PrinterJob.getPrinterJob();
    pjob.setJobName(docName);
    Book book = new Book();
    PDFPrintPage pages = new PDFPrintPage(curFile);
    book.append(pages, pformat, curFile.getNumPages());

    pjob.setPageable(book);
    if (pjob.printDialog()) {
        new PrintThread(pages, pjob).start();
    }
}
 
開發者ID:proofy,項目名稱:willow-browser,代碼行數:16,代碼來源:PDFViewer.java

示例4: printFile

import java.awt.print.Book; //導入依賴的package包/類
public void printFile() {
    PrinterJob print = PrinterJob.getPrinterJob();
    PageFormat format = print.pageDialog(new PageFormat());
    if (print.printDialog()) {
        Book b = new Book();
        b.append((Printable)this.bufferGraphics, format);
        print.setPageable(b);
        try { print.print(); }
            catch(PrinterException ex) { ex.printStackTrace(); }
    }
}
 
開發者ID:cjd5551,項目名稱:Java_Paint,代碼行數:12,代碼來源:Paint_GUI.java

示例5: actionPerformed

import java.awt.print.Book; //導入依賴的package包/類
public void actionPerformed(ActionEvent e) {
	
	// Get the print manager
	PrinterJob printJob = PrinterJob.getPrinterJob();
	Book book = new Book();
	int pages = getEditor().getBoardContainerCount();
	for (int i = 0; i < pages; i++) {
		TBoardContainer boardContainer = getEditor().getBoardContainer(i);
		// Clear selection
		boardContainer.getBoard().clearSelection();
		Dimension boardSize = TBoardConstants.getSize(boardContainer.getBoard().getAttributes(null));
		PageFormat page = printJob.defaultPage();
		if (boardSize.getWidth() > boardSize.getHeight())
			page.setOrientation(PageFormat.LANDSCAPE);
		else
			page.setOrientation(PageFormat.PORTRAIT);
		book.append(boardContainer, page);
	}
	// Set the component to print
	printJob.setPageable(book);
	if (printJob.printDialog()) {
		try {
			printJob.print();
		} catch (Exception ex) {
			// If the print fails show an error message
			JOptionPane.showMessageDialog(null,
					TLanguage.getString("TProjectPrintAction.PRINT_ERROR"),
					TLanguage.getString("TProjectPrintAction.ERROR") + "!",
					JOptionPane.ERROR_MESSAGE);
		}
	}
}
 
開發者ID:ProgettoRadis,項目名稱:ArasuiteIta,代碼行數:33,代碼來源:TProjectPrintAction.java

示例6: printPopG

import java.awt.print.Book; //導入依賴的package包/類
public void printPopG() {
	PrinterJob pj = PrinterJob.getPrinterJob(); 
    Book book = new Book();
    PageFormat documentPageFormat = new PageFormat();
    documentPageFormat.setOrientation(PageFormat.LANDSCAPE);
    book.append(new Document(), documentPageFormat);
    pj.setPageable(book);
    if (pj.printDialog()) {
        try {
        	pj.print();
       	} catch (Exception PrintException) {
       		PrintException.printStackTrace();
        }
      }
}
 
開發者ID:mars-sim,項目名稱:mars-sim,代碼行數:16,代碼來源:PopGUserInterface.java

示例7: print

import java.awt.print.Book; //導入依賴的package包/類
public void print() {
	PrinterJob printerJob = PrinterJob.getPrinterJob();
	Book book = new Book();
	book.append(new PrintPage(), pageFormat);
	printerJob.setPageable(book);
	boolean doPrint = printerJob.printDialog();
	if (doPrint) {
		try {
			printerJob.print();
		} catch (PrinterException exception) {
			System.err.println("Printing error: " + exception);
		}
	}
}
 
開發者ID:ujmp,項目名稱:universal-java-matrix-package,代碼行數:15,代碼來源:PrintPreviewPanel.java

示例8: print

import java.awt.print.Book; //導入依賴的package包/類
private void print(final PrintPackageRequest request) throws PrinterException
{
	logger.log(Level.FINE, "Printing request {}", request);

	// Create Print Job
	final PrinterJob pjob = PrinterJob.getPrinterJob();
	pjob.setJobName(request.getPrintJobName());

	final PageFormat pf = pjob.defaultPage();
	final Paper paper = pjob.defaultPage().getPaper();
	final MediaSize size = MediaSize.getMediaSizeForName(MediaSizeName.ISO_A4);

	paper.setSize(size.getSize(Size2DSyntax.INCH)[0] * 72, size.getSize(Size2DSyntax.INCH)[1] * 72);
	paper.setImageableArea(0, 0, size.getSize(Size2DSyntax.INCH)[0] * 72, size.getSize(Size2DSyntax.INCH)[1] * 72);
	pf.setPaper(paper);

	final Book book = new Book();// java.awt.print.Book
	book.append(request.getPrintable(), pf, request.getNumPages());
	pjob.setPageable(book);

	pjob.setPrintService(request.getPrintService());
	pjob.print(request.getAttributes());

	// task 09618: allow us to configure the client to return an error even if everything went OK, so we can test
	final String alwaysReturnError = Context.getContext().getProperty(Context.CTX_Testing_AlwaysReturnError, Context.DEFAULT_AlwaysReturnError);
	if (Boolean.parseBoolean(alwaysReturnError))
	{
		logger.log(Level.INFO, "{} is true, so we report an error, despite the print was OK", Context.CTX_Testing_AlwaysReturnError);

		final String errorMsg = Context.getContext().getProperty(Context.CTX_Testing_ErrorMessage, Context.DEFAULT_ErrorMessage);
		throw new PrinterException(errorMsg);
	}
}
 
開發者ID:metasfresh,項目名稱:metasfresh,代碼行數:34,代碼來源:PrintingEngine.java

示例9: print

import java.awt.print.Book; //導入依賴的package包/類
/**
 * Constructs a new PrinterJob, allows the user to select which printer to
 * print to, And then prints the node.
 * @throws PrinterException if print fails
 */
public void print() throws PrinterException {
    final PrinterJob printJob = PrinterJob.getPrinterJob();
    final PageFormat pageFormat = printJob.defaultPage();
    final Book book = new Book();
    book.append(this, pageFormat);
    printJob.setPageable(book);

    if (printJob.printDialog()) {
        printJob.print();
    }
}
 
開發者ID:piccolo2d,項目名稱:piccolo2d.java,代碼行數:17,代碼來源:PNode.java

示例10: createBook

import java.awt.print.Book; //導入依賴的package包/類
/** Méthode qui formatte le contenu de l'éditeur en pages, rangées dans un Book.
 * Cette méthode modifie les variables book et pages.
 **/
public Book createBook() {
    book = new Book();
    pages = decouperEnPages();
    book.append(this, page, pages.size());
    return book;
}
 
開發者ID:Sharcoux,項目名稱:MathEOS,代碼行數:10,代碼來源:Formatter.java

示例11: doPrint

import java.awt.print.Book; //導入依賴的package包/類
/**
 * Print the current document.
 */
public void doPrint() {
	PrinterJob pjob = PrinterJob.getPrinterJob();
	pjob.setJobName(docName);
	Book book = new Book();
	PDFPrintPage pages = new PDFPrintPage(curFile);
	book.append(pages, pformat, curFile.getNumPages());
	pjob.setPageable(book);
	if (pjob.printDialog()) {
		new PrintThread(pages, pjob).start();
	}
}
 
開發者ID:oswetto,項目名稱:LoboEvolution,代碼行數:15,代碼來源:PdfDialog.java

示例12: print

import java.awt.print.Book; //導入依賴的package包/類
/**
 * Print circuit currently being edited, plus any state machines.
 * 
 * @param all True to print the entire circuit, false to print just what's visible.
 */
public void print(boolean all) {

	// get the currently selected editor, return if none
	Editor ed = (Editor)(edits.getSelectedComponent());
	if (ed == null)
		return;

	// set up printer job
	PrinterJob job = PrinterJob.getPrinterJob();
	PageFormat format = job.defaultPage();
	format.setOrientation(PageFormat.LANDSCAPE);
	Book book = new Book();

	// find all unique sub-circuits (and their state machines)
	if (all) {
		ed.getCircuit().addToBook(book,format);
	}
	else {
		book.append(ed.getCircuit(),format);
	}

	// finish up book
	job.setPageable(book);

	// show dialog, and if ok, print
	if (job.printDialog()) {
		try {
			job.print();
		}
		catch (PrinterException ex) {
			System.out.println("printing error: " + ex.getMessage());
		}
	}
}
 
開發者ID:anadon,項目名稱:JLS,代碼行數:40,代碼來源:JLSStart.java

示例13: printPages

import java.awt.print.Book; //導入依賴的package包/類
void printPages() {

			U.startThread(new Thread() {
				@Override
				public void run() {
					try {
						PrinterJob job = PrinterJob.getPrinterJob();
						PageFormat pf = job.pageDialog(job.defaultPage());
						totalPage = getTotalPage(pf);
						if (totalPage <= 0) {
							return;
						}
						dim = new Dimension((int) pf.getImageableWidth(), (int) pf.getImageableHeight());
						Book bk = new Book();
						bk.append(Print.this, pf, totalPage);
						job.setPageable(bk);
						if (job.printDialog()) {
							ui.message("printing...");
							uiComp.repaint();
							job.print();
							ui.message("print ok");
							uiComp.repaint();
						}
					} catch (Exception e) {
						ui.message("err:" + e);
						uiComp.repaint();
						e.printStackTrace();
					}
				}
			});
		}
 
開發者ID:neoedmund,項目名稱:neoeedit,代碼行數:32,代碼來源:U.java

示例14: main

import java.awt.print.Book; //導入依賴的package包/類
public static void main(String args[]) {
    new Book().getNumberOfPages();
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:4,代碼來源:HeadlessBook.java

示例15: printInfo

import java.awt.print.Book; //導入依賴的package包/類
public void printInfo() throws Exception{
//		int height = 225+15*foodInfos.size();
		int height = getHeight();
		
		Book book = new Book();
		//設置成豎打 
	    PageFormat pf = new PageFormat();
	    pf.setOrientation(PageFormat.PORTRAIT);
	    
	    //通過Paper設置頁麵的空白邊距和可打印區域。必須與實際打印紙張大小相符。  
	    
	    Paper p = new Paper();
//	    p.setSize(590, 840);
	    p.setSize(163,height);//紙張大小
	    //A4(595 X 842)設置打印區域,其實0,0應該是72,72,因為A4紙的默認X,Y邊距是72
//	    p.setImageableArea(10,10, 590,840);
	    p.setImageableArea(start_x, -20, 163, height + 20);
	    pf.setPaper(p);
	    
	    //把 PageFormat 和 Printable 添加到書中,組成一個頁麵 
	    book.append(this, pf);
	    
	    //獲取打印機服務對象, 默認打印機
	    PrinterJob job = PrinterJob.getPrinterJob();
	    logger.info("#printInfo. jobName: "+job.getJobName()+", userName; "+job.getUserName());
	    logger.info("#printInfo. 打印機名稱: "+job.getPrintService().getName());
	    
	    //日誌輸出打印機的各項屬性  
        AttributeSet attrs = job.getPrintService().getAttributes();
        logger.info("****************************************************");
        for (Attribute attr : attrs.toArray()) {
            String attributeName = attr.getName();
            String attributeValue = attrs.get(attr.getClass()).toString();
            logger.info("*"+attributeName + " : " + attributeValue);
        }
        logger.info("****************************************************");
        
	    //設置打印類
	    job.setPageable(book);
	    
        //可以用printDialog顯示打印對話框,在用戶確認後打印;也可以直接打印 
        /*boolean a=job.printDialog();
        logger.info("#print. a="+a);*/
	    
	    job.print();
	    
	}
 
開發者ID:hanwwh,項目名稱:xqres,代碼行數:48,代碼來源:PrinterInfo.java


注:本文中的java.awt.print.Book類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。