当前位置: 首页>>代码示例>>Java>>正文


Java ServiceUI类代码示例

本文整理汇总了Java中javax.print.ServiceUI的典型用法代码示例。如果您正苦于以下问题:Java ServiceUI类的具体用法?Java ServiceUI怎么用?Java ServiceUI使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ServiceUI类属于javax.print包,在下文中一共展示了ServiceUI类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: printTest

import javax.print.ServiceUI; //导入依赖的package包/类
/**
 * Starts the application.
 */
public static void printTest() {

    System.out.println("\nDefault print service: " +
                          PrintServiceLookup.lookupDefaultPrintService());
    System.out.println("is flavor: "+flavor+" supported? "+
                                 services[0].isDocFlavorSupported(flavor));
    System.out.println("is Page Ranges category supported? "+
               services[0].isAttributeCategorySupported(PageRanges.class));
    System.out.println("is PageRanges[2] value supported ? "+
               services[0].isAttributeValueSupported(
                                         new PageRanges(2), flavor, null));

    HashPrintRequestAttributeSet prSet = new HashPrintRequestAttributeSet();
    //prSet.add(new PageRanges(2));
    PrintService selService = ServiceUI.printDialog(null, 200, 200,
                                      services, services[0], flavor, prSet);

    System.out.println("\nSelected Values\n");
    Attribute attr[] = prSet.toArray();
    for (int x = 0; x < attr.length; x ++) {
        System.out.println("Attribute: " + attr[x].getName() +
                                                    " Value: " + attr[x]);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:28,代码来源:ServiceDlgPageRangeTest.java

示例2: printDialog

import javax.print.ServiceUI; //导入依赖的package包/类
/**
 * Displays a dialog box to the user which allows the print job
 * attributes to be modified.
 *
 * @return <code>false</code> if the user cancels the dialog box,
 * <code>true</code> otherwise.
 */
public boolean printDialog(PrintRequestAttributeSet attributes)
  throws HeadlessException
{
  PrintService chosenPrinter = ServiceUI.printDialog
    (null, 50, 50, services, null,
     DocFlavor.INPUT_STREAM.POSTSCRIPT, attributes);

  getPageAttributes();

  if( chosenPrinter != null )
    {
      try
        {
          setPrintService( chosenPrinter );
        }
      catch(PrinterException pe)
        {
          // Should not happen.
        }
      return true;
    }
  return false;
}
 
开发者ID:vilie,项目名称:javify,代码行数:31,代码来源:JavaPrinterJob.java

示例3: printDialog

import javax.print.ServiceUI; //导入依赖的package包/类
/**
  * Displays a dialog box to the user which allows the print job
  * attributes to be modified.
  *
  * @return <code>false</code> if the user cancels the dialog box,
  * <code>true</code> otherwise.
  */
 public boolean printDialog(PrintRequestAttributeSet attributes)
   throws HeadlessException
 {
   PrintService chosenPrinter = ServiceUI.printDialog
     (null, 50, 50, services, null, 
      DocFlavor.INPUT_STREAM.POSTSCRIPT, attributes);

   getPageAttributes();

   if( chosenPrinter != null )
     {
try
  {
    setPrintService( chosenPrinter );
  }
catch(PrinterException pe)
  {
    // Should not happen.
  }
return true;
     }
   return false;
 }
 
开发者ID:nmldiegues,项目名称:jvm-stm,代码行数:31,代码来源:JavaPrinterJob.java

示例4: out

import javax.print.ServiceUI; //导入依赖的package包/类
public static boolean out(BufferedImage image) {
	try {
		DocFlavor flavor = DocFlavor.SERVICE_FORMATTED.PRINTABLE;
		PrintRequestAttributeSet requestAttributeSet = new HashPrintRequestAttributeSet();
		requestAttributeSet.add(MediaSizeName.ISO_A4);
		requestAttributeSet.add(new JobName(LSystem.applicationName + LSystem.getTime(), Locale.ENGLISH));
		PrintService[] services = PrintServiceLookup.lookupPrintServices(flavor, requestAttributeSet);
		PrintService defaultService = PrintServiceLookup.lookupDefaultPrintService();
		PrintService service = ServiceUI.printDialog(null, 100, 100, services, defaultService, flavor,
				requestAttributeSet);
		if (service != null) {
			DocPrintJob job = service.createPrintJob();
			SimpleDoc doc = new SimpleDoc(new BufferedImagePrintable(image), flavor, null);
			job.print(doc, requestAttributeSet);
		}
	} catch (Exception e) {
		return false;
	}
	return true;
}
 
开发者ID:cping,项目名称:RipplePower,代码行数:21,代码来源:PrintImageOutput.java

示例5: printDialog

import javax.print.ServiceUI; //导入依赖的package包/类
@Override
public boolean printDialog(final PrintRequestAttributeSet attributes)
                throws HeadlessException {
    checkHeadless();

    if (attributes == null) {
        throw new NullPointerException();
    }

    final PrintRequestAttributeSet attrs = mergeAttrs(attributes);
    final Rectangle screen = GraphicsEnvironment
                    .getLocalGraphicsEnvironment().getDefaultScreenDevice()
                    .getDefaultConfiguration().getBounds();
    final PrintService newService = ServiceUI.printDialog(null,
                    screen.width / 3, screen.height / 3,
                    lookupPrintServices(), getPrintService(),
                    DocFlavor.SERVICE_FORMATTED.PRINTABLE, attrs);

    if (newService != null) {
        printService = newService;
    }

    return newService != null;
}
 
开发者ID:shannah,项目名称:cn1,代码行数:25,代码来源:PrinterJobImpl.java

示例6: printComponent

import javax.print.ServiceUI; //导入依赖的package包/类
public static void printComponent(Component c) {
  // Get a list of all printers that can handle Printable objects.
  DocFlavor flavor = DocFlavor.SERVICE_FORMATTED.PRINTABLE;
  PrintService[] services = PrintServiceLookup.lookupPrintServices(flavor, null);
  // Set some define printing attributes
  PrintRequestAttributeSet printAttributes = new HashPrintRequestAttributeSet();
  //printAttributes.add(OrientationRequested.LANDSCAPE); // landscape mode
  printAttributes.add(OrientationRequested.PORTRAIT);                    // PORTRAIT mode
  printAttributes.add(Chromaticity.MONOCHROME);                          // print in mono
  printAttributes.add(javax.print.attribute.standard.PrintQuality.HIGH); // highest resolution
  // Display a dialog that allows the user to select one of the
  // available printers and to edit the default attributes
  PrintService service = ServiceUI.printDialog(null, 100, 100, services, null, null, printAttributes);
  // If the user canceled, don't do anything
  if(service==null) {
    return;
  }
  // Now call a method defined below to finish the printing
  printToService(c, service, printAttributes);
}
 
开发者ID:OpenSourcePhysics,项目名称:osp,代码行数:21,代码来源:PrintUtils.java

示例7: printTest

import javax.print.ServiceUI; //导入依赖的package包/类
private static void printTest() {
    ServiceDlgSheetCollateTest pd = new ServiceDlgSheetCollateTest();
    DocFlavor flavor = DocFlavor.INPUT_STREAM.JPEG;
    //DocFlavor flavor = DocFlavor.SERVICE_FORMATTED.PRINTABLE;
    PrintService defService = null, service[] = null;
    defService = PrintServiceLookup.lookupDefaultPrintService();
    service = PrintServiceLookup.lookupPrintServices(flavor, null);

    if ((service == null) || (service.length == 0)) {
        throw new RuntimeException("No Printer services found");
    }
    if (defService != null) {
        System.out.println("\nDefault print service: " + service );
        System.out.println("is flavor: "+flavor+" supported? "+
                        defService.isDocFlavorSupported(flavor));
        System.out.println("is SheetCollate category supported? "+
              defService.isAttributeCategorySupported(SheetCollate.class));
        System.out.println("is SheetCollate.COLLATED value supported ? "+
              defService.isAttributeValueSupported(SheetCollate.COLLATED,
                                                        flavor, null));
    }
    HashPrintRequestAttributeSet prSet = new HashPrintRequestAttributeSet();
    try {
        PrintService selService = ServiceUI.printDialog(null, 200, 200, service, defService, flavor, prSet);
    } catch (IllegalArgumentException ia) {
        System.out.println("Exception thrown : " + ia);
    }

    System.out.println("\nSelected Values\n");
    Attribute attr[] = prSet.toArray();
    for (int x = 0; x < attr.length; x ++) {
        System.out.println("Attribute: " + attr[x].getName() + " Value: " + attr[x]);
    }

}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:36,代码来源:ServiceDlgSheetCollateTest.java

示例8: printTest

import javax.print.ServiceUI; //导入依赖的package包/类
private static void printTest() {
    PrintService defService = null, service[] = null;
    HashPrintRequestAttributeSet prSet = new HashPrintRequestAttributeSet();
    DocFlavor flavor = DocFlavor.INPUT_STREAM.JPEG;

    service = PrintServiceLookup.lookupPrintServices(flavor, null);
    defService = PrintServiceLookup.lookupDefaultPrintService();

    if ((service == null) || (service.length == 0)) {
        throw new RuntimeException("No Printer services found");
    }
    File f = new File("output.ps");
    Destination d = new Destination(f.toURI());
    prSet.add(d);
    if (defService != null) {
        System.out.println("isAttrCategory Supported? " +
                defService.isAttributeCategorySupported(Destination.class));
        System.out.println("isAttrValue Supported? " +
                defService.isAttributeValueSupported(d, flavor, null));
    }

    defService = ServiceUI.printDialog(null, 100, 100, service, defService,
            flavor, prSet);

    ServiceUI.printDialog(null, 100, 100, service, defService,
            DocFlavor.SERVICE_FORMATTED.PAGEABLE,
            new HashPrintRequestAttributeSet());
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:29,代码来源:ServiceDialogValidateTest.java

示例9: createDocPrintJob

import javax.print.ServiceUI; //导入依赖的package包/类
private DocPrintJob createDocPrintJob() {
    PrintService[] services = PrintServiceLookup.lookupPrintServices(
            DocFlavor.SERVICE_FORMATTED.PAGEABLE, null);
    PrintRequestAttributeSet attributes = new HashPrintRequestAttributeSet();
    PrintService printService = ServiceUI.printDialog(null, 50, 50,
            services, services[0], null, attributes);
    if (printService != null) {
        return printService.createPrintJob();
    } else {
        return null;
    }
}
 
开发者ID:pellcorp,项目名称:fop,代码行数:13,代码来源:ExampleFO2JPSPrint.java

示例10: showPrintJDialog

import javax.print.ServiceUI; //导入依赖的package包/类
final public Boolean showPrintJDialog() {

		final PrintService objLdefaultPrintService = PrintServiceLookup.lookupDefaultPrintService();
		final PrintRequestAttributeSet objLprintRequestAttributeSet = new HashPrintRequestAttributeSet();

		if (this.objGprintServiceA.length > 0) {
			int intLdefaultServiceIndex = 0;
			if (objLdefaultPrintService != null) {
				for (intLdefaultServiceIndex = 0; intLdefaultServiceIndex < this.objGprintServiceA.length; intLdefaultServiceIndex++) {
					if (this.objGprintServiceA[intLdefaultServiceIndex].equals(objLdefaultPrintService)) {
						break;
					}
				}
			}
			if (intLdefaultServiceIndex == this.objGprintServiceA.length) {
				intLdefaultServiceIndex = 0;
			}

			ServiceUI.printDialog(	null,
									50,
									50,
									this.objGprintServiceA,
									this.objGprintServiceA[intLdefaultServiceIndex],
									null,
									objLprintRequestAttributeSet);

			final PrintJDialog objLprintJDialog = new PrintJDialog(this.objGcontrolJFrame, this.objGprintServiceA, intLdefaultServiceIndex);
			objLprintJDialog.setVisible();
			final PrintService objLprintService = objLprintJDialog.getPrintService();
			objLprintJDialog.dispose();

			if (objLprintService != null) {
				final DocPrintJob objLdocPrintJob = objLprintService.createPrintJob();
				final SimpleDoc objLsimpleDoc = new SimpleDoc(this, DocFlavor.SERVICE_FORMATTED.PRINTABLE, null);
				try {
					objLdocPrintJob.print(objLsimpleDoc, objLprintRequestAttributeSet);
					return new Boolean(true);
				} catch (final Throwable objPthrowable) {}
			} else {
				return null;
			}
		} else {
			new PopUpJDialog(	this.objGcontrolJFrame,
								Constants.bytS_UNCLASS_NO_VALUE,
								Constants.intS_FILE_ICON_ALERT,
								this.objGcontrolJFrame.getLanguageString(Language.intS_TITLE_PRINT_PATTERN),
								Tools.getLocaleString("dialog.noprintermsg"),
								null,
								true);
		}
		return new Boolean(false);
	}
 
开发者ID:jugglemaster,项目名称:JuggleMasterPro,代码行数:53,代码来源:ImagesPrinter.java

示例11: printDialog

import javax.print.ServiceUI; //导入依赖的package包/类
public boolean printDialog(PrintRequestAttributeSet dialogAttrs)
        throws HeadlessException {

    if (dialogAttrs == null) {
        throw new NullPointerException();
    } else if (GraphicsEnvironment.isHeadless()) {
        throw new HeadlessException();
    }

    /* Combine this PrinterJob attrs attribute set and printerAttrs set
       and resolve MediaPrintableArea/MediaMargins conflict if it is 
       needed */
    PrintRequestAttributeSet sum = 
            updateMediaAndMarginsIfNeeded(dialogAttrs);

    Rectangle screen = GraphicsEnvironment.getLocalGraphicsEnvironment().
            getDefaultScreenDevice().getDefaultConfiguration().getBounds();

    /* call cross-platform print dialog */
    PrintService newSrv = ServiceUI.printDialog(
            null, 
            screen.width / 3, 
            screen.height / 3, 
            lookupServicesForDialog(), 
            service,
            DocFlavor.SERVICE_FORMATTED.PRINTABLE, 
            sum);

    if (newSrv!=null) {
        /* Set selected print service and update attrs attribute set 
           if user clicked "Print" button */
        try {
            setPrintService(newSrv);
            this.attrs.clear();
            this.attrs.addAll(sum);
            return true;
        } catch (PrinterException e) {
            System.out.println(e);
            return false;
        }
    }
    return false;   /* "Cancel button was pressed */
}
 
开发者ID:shannah,项目名称:cn1,代码行数:44,代码来源:PSPrinterJob.java


注:本文中的javax.print.ServiceUI类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。