本文整理汇总了Java中java.awt.JobAttributes类的典型用法代码示例。如果您正苦于以下问题:Java JobAttributes类的具体用法?Java JobAttributes怎么用?Java JobAttributes使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
JobAttributes类属于java.awt包,在下文中一共展示了JobAttributes类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: set
import java.awt.JobAttributes; //导入依赖的package包/类
/**
* Sets all of the attributes of this <code>JobAttributes</code> to
* the same values as the attributes of obj.
*
* @param obj the <code>JobAttributes</code> to copy
*/
public void set(JobAttributes obj) {
copies = obj.copies;
defaultSelection = obj.defaultSelection;
destination = obj.destination;
dialog = obj.dialog;
fileName = obj.fileName;
fromPage = obj.fromPage;
maxPage = obj.maxPage;
minPage = obj.minPage;
multipleDocumentHandling = obj.multipleDocumentHandling;
// okay because we never modify the contents of pageRanges
pageRanges = obj.pageRanges;
prFirst = obj.prFirst;
prLast = obj.prLast;
printer = obj.printer;
sides = obj.sides;
toPage = obj.toPage;
}
示例2: set
import java.awt.JobAttributes; //导入依赖的package包/类
/**
* Sets all of the attributes of this {@code JobAttributes} to
* the same values as the attributes of obj.
*
* @param obj the {@code JobAttributes} to copy
*/
public void set(JobAttributes obj) {
copies = obj.copies;
defaultSelection = obj.defaultSelection;
destination = obj.destination;
dialog = obj.dialog;
fileName = obj.fileName;
fromPage = obj.fromPage;
maxPage = obj.maxPage;
minPage = obj.minPage;
multipleDocumentHandling = obj.multipleDocumentHandling;
// okay because we never modify the contents of pageRanges
pageRanges = obj.pageRanges;
prFirst = obj.prFirst;
prLast = obj.prLast;
printer = obj.printer;
sides = obj.sides;
toPage = obj.toPage;
}
示例3: printTest
import java.awt.JobAttributes; //导入依赖的package包/类
private static void printTest() {
JobAttributes ja = new JobAttributes();
Toolkit tk = Toolkit.getDefaultToolkit();
// ja.setToPage(4);
// ja.setFromPage(3);
// show dialog
PrintJob pjob = tk.getPrintJob(new JFrame(), "test", ja, null);
if (pjob == null) {
return;
}
if (ja.getDefaultSelection() == JobAttributes.DefaultSelectionType.RANGE) {
int fromPage = ja.getFromPage();
int toPage = ja.getToPage();
if (fromPage != 2 || toPage != 3) {
fail();
} else {
pass();
}
}
}
示例4: main
import java.awt.JobAttributes; //导入依赖的package包/类
public static void main(String[] args) {
Toolkit tk = Toolkit.getDefaultToolkit();
PrintJob pj = null;
int[][] pageRange = new int[][]{new int[]{1,1}};
JobAttributes ja = new JobAttributes(1,
java.awt.JobAttributes.DefaultSelectionType.ALL,
JobAttributes.DestinationType.FILE, JobAttributes.DialogType.NATIVE,
"", Integer.MAX_VALUE, 1,
JobAttributes.MultipleDocumentHandlingType.SEPARATE_DOCUMENTS_UNCOLLATED_COPIES,
pageRange, "", JobAttributes.SidesType.ONE_SIDED);
Frame testFrame = new Frame("print");
if (tk != null) {
pj = tk.getPrintJob(testFrame, null, ja, null);
}
}
示例5: set
import java.awt.JobAttributes; //导入依赖的package包/类
/**
* Sets all of the attributes of this <code>JobAttributes</code> to
* the same values as the attributes of obj.
*
* @param obj the <code>JobAttributes</code> to copy
*/
public void set(JobAttributes obj) {
copies = obj.copies;
defaultSelection = obj.defaultSelection;
destination = obj.destination;
dialog = obj.dialog;
fileName = obj.fileName;
fromPage = obj.fromPage;
maxPage = obj.maxPage;
minPage = obj.minPage;
multipleDocumentHandling = obj.multipleDocumentHandling;
// okay because we never modify the contents of pageRanges
pageRanges = obj.pageRanges;
prFirst = obj.prFirst;
prLast = obj.prLast;
printer = obj.printer;
sides = obj.sides;
toPage = obj.toPage;
}
示例6: PrintJob2D
import java.awt.JobAttributes; //导入依赖的package包/类
public PrintJob2D(Frame frame, String doctitle,
final Properties props) {
this.props = props;
this.jobAttributes = new JobAttributes();
this.pageAttributes = new PageAttributes();
translateInputProps();
initPrintJob2D(frame, doctitle,
this.jobAttributes, this.pageAttributes);
}
示例7: main
import java.awt.JobAttributes; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
Robot robot = new Robot();
Thread t = new Thread (() -> {
robot.waitForIdle();
robot.delay(2000);
robot.keyPress(KeyEvent.VK_ESCAPE);
robot.keyRelease(KeyEvent.VK_ESCAPE);
});
Toolkit tk = Toolkit.getDefaultToolkit();
PrintJob pj = null;
int[][] pageRange = new int[][]{new int[]{1,1}};
JobAttributes ja = new JobAttributes(1,
java.awt.JobAttributes.DefaultSelectionType.ALL,
JobAttributes.DestinationType.FILE, JobAttributes.DialogType.NATIVE,
"filename.ps", Integer.MAX_VALUE, 1,
JobAttributes.MultipleDocumentHandlingType.SEPARATE_DOCUMENTS_UNCOLLATED_COPIES,
pageRange, "", JobAttributes.SidesType.ONE_SIDED);
Frame testFrame = new Frame("print");
try {
if (tk != null) {
t.start();
pj = tk.getPrintJob(testFrame, null, ja, null);
}
} finally {
testFrame.dispose();
}
}
示例8: main
import java.awt.JobAttributes; //导入依赖的package包/类
public static void main(String[] args) {
JobAttributes ja = new JobAttributes();
ja.setDialog(JobAttributes.DialogType.COMMON);
boolean npeThrown = false;
try {
Toolkit.getDefaultToolkit().getPrintJob(null,
"test Printing", ja, null);
} catch (NullPointerException ex) {
npeThrown = true;
}
if (!npeThrown) {
throw
new RuntimeException("getPrintJob didn't throw NPE for null Frame");
}
}
示例9: printTest
import java.awt.JobAttributes; //导入依赖的package包/类
private static void printTest() {
JobAttributes job = new JobAttributes();
PageAttributes page = new PageAttributes();
job.setDialog(JobAttributes.DialogType.NATIVE);
job.setDefaultSelection(JobAttributes.DefaultSelectionType.ALL);
job.setFromPage(2);
job.setToPage(5);
Toolkit tk = Toolkit.getDefaultToolkit();
// setting this dialog to native printdialog
if (tk != null) {
PrintJob pj = tk.getPrintJob(new JFrame(),
"testing the attribute setting ", job, page);
}
}
示例10: JobAttributes
import java.awt.JobAttributes; //导入依赖的package包/类
/**
* Constructs a <code>JobAttributes</code> instance with the
* specified values for every attribute.
*
* @param copies an integer greater than 0
* @param defaultSelection <code>DefaultSelectionType.ALL</code>,
* <code>DefaultSelectionType.RANGE</code>, or
* <code>DefaultSelectionType.SELECTION</code>
* @param destination <code>DesintationType.FILE</code> or
* <code>DesintationType.PRINTER</code>
* @param dialog <code>DialogType.COMMON</code>,
* <code>DialogType.NATIVE</code>, or
* <code>DialogType.NONE</code>
* @param fileName the possibly <code>null</code> file name
* @param maxPage an integer greater than zero and greater than or equal
* to <i>minPage</i>
* @param minPage an integer greater than zero and less than or equal
* to <i>maxPage</i>
* @param multipleDocumentHandling
* <code>MultipleDocumentHandlingType.SEPARATE_DOCUMENTS_COLLATED_COPIES</code> or
* <code>MultipleDocumentHandlingType.SEPARATE_DOCUMENTS_UNCOLLATED_COPIES</code>
* @param pageRanges an array of integer arrays of two elements; an array
* is interpreted as a range spanning all pages including and
* between the specified pages; ranges must be in ascending
* order and must not overlap; specified page numbers cannot be
* less than <i>minPage</i> nor greater than <i>maxPage</i>;
* for example:
* <pre>
* (new int[][] { new int[] { 1, 3 }, new int[] { 5, 5 },
* new int[] { 15, 19 } }),
* </pre>
* specifies pages 1, 2, 3, 5, 15, 16, 17, 18, and 19. Note that
* (<code>new int[][] { new int[] { 1, 1 }, new int[] { 1, 2 } }</code>),
* is an invalid set of page ranges because the two ranges
* overlap
* @param printer the possibly <code>null</code> printer name
* @param sides <code>SidesType.ONE_SIDED</code>,
* <code>SidesType.TWO_SIDED_LONG_EDGE</code>, or
* <code>SidesType.TWO_SIDED_SHORT_EDGE</code>
* @throws IllegalArgumentException if one or more of the above
* conditions is violated
*/
public JobAttributes(int copies, DefaultSelectionType defaultSelection,
DestinationType destination, DialogType dialog,
String fileName, int maxPage, int minPage,
MultipleDocumentHandlingType multipleDocumentHandling,
int[][] pageRanges, String printer, SidesType sides) {
setCopies(copies);
setDefaultSelection(defaultSelection);
setDestination(destination);
setDialog(dialog);
setFileName(fileName);
setMaxPage(maxPage);
setMinPage(minPage);
setMultipleDocumentHandling(multipleDocumentHandling);
setPageRanges(pageRanges);
setPrinter(printer);
setSides(sides);
}
示例11: equals
import java.awt.JobAttributes; //导入依赖的package包/类
/**
* Determines whether two JobAttributes are equal to each other.
* <p>
* Two JobAttributes are equal if and only if each of their attributes are
* equal. Attributes of enumeration type are equal if and only if the
* fields refer to the same unique enumeration object. A set of page
* ranges is equal if and only if the sets are of equal length, each range
* enumerates the same pages, and the ranges are in the same order.
*
* @param obj the object whose equality will be checked.
* @return whether obj is equal to this JobAttribute according to the
* above criteria.
*/
public boolean equals(Object obj) {
if (!(obj instanceof JobAttributes)) {
return false;
}
JobAttributes rhs = (JobAttributes)obj;
if (fileName == null) {
if (rhs.fileName != null) {
return false;
}
} else {
if (!fileName.equals(rhs.fileName)) {
return false;
}
}
if (pageRanges == null) {
if (rhs.pageRanges != null) {
return false;
}
} else {
if (rhs.pageRanges == null ||
pageRanges.length != rhs.pageRanges.length) {
return false;
}
for (int i = 0; i < pageRanges.length; i++) {
if (pageRanges[i][0] != rhs.pageRanges[i][0] ||
pageRanges[i][1] != rhs.pageRanges[i][1]) {
return false;
}
}
}
if (printer == null) {
if (rhs.printer != null) {
return false;
}
} else {
if (!printer.equals(rhs.printer)) {
return false;
}
}
return (copies == rhs.copies &&
defaultSelection == rhs.defaultSelection &&
destination == rhs.destination &&
dialog == rhs.dialog &&
fromPage == rhs.fromPage &&
maxPage == rhs.maxPage &&
minPage == rhs.minPage &&
multipleDocumentHandling == rhs.multipleDocumentHandling &&
prFirst == rhs.prFirst &&
prLast == rhs.prLast &&
sides == rhs.sides &&
toPage == rhs.toPage);
}