本文整理汇总了Java中sun.print.ServiceDialog类的典型用法代码示例。如果您正苦于以下问题:Java ServiceDialog类的具体用法?Java ServiceDialog怎么用?Java ServiceDialog使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ServiceDialog类属于sun.print包,在下文中一共展示了ServiceDialog类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: displayNativeDialog
import sun.print.ServiceDialog; //导入依赖的package包/类
private boolean displayNativeDialog() {
// "attributes" is required for getting the updated attributes
if (attributes == null) {
return false;
}
DialogOwner dlgOwner = (DialogOwner)attributes.get(DialogOwner.class);
Frame ownerFrame = (dlgOwner != null) ? dlgOwner.getOwner() : null;
WPrintDialog dialog = new WPrintDialog(ownerFrame, this);
dialog.setRetVal(false);
dialog.setVisible(true);
boolean prv = dialog.getRetVal();
dialog.dispose();
Destination dest =
(Destination)attributes.get(Destination.class);
if ((dest == null) || !prv){
return prv;
} else {
String title = null;
String strBundle = "sun.print.resources.serviceui";
ResourceBundle rb = ResourceBundle.getBundle(strBundle);
try {
title = rb.getString("dialog.printtofile");
} catch (MissingResourceException e) {
}
FileDialog fileDialog = new FileDialog(ownerFrame, title,
FileDialog.SAVE);
URI destURI = dest.getURI();
// Old code destURI.getPath() would return null for "file:out.prn"
// so we use getSchemeSpecificPart instead.
String pathName = (destURI != null) ?
destURI.getSchemeSpecificPart() : null;
if (pathName != null) {
File file = new File(pathName);
fileDialog.setFile(file.getName());
File parent = file.getParentFile();
if (parent != null) {
fileDialog.setDirectory(parent.getPath());
}
} else {
fileDialog.setFile("out.prn");
}
fileDialog.setVisible(true);
String fileName = fileDialog.getFile();
if (fileName == null) {
fileDialog.dispose();
return false;
}
String fullName = fileDialog.getDirectory() + fileName;
File f = new File(fullName);
File pFile = f.getParentFile();
while ((f.exists() &&
(!f.isFile() || !f.canWrite())) ||
((pFile != null) &&
(!pFile.exists() || (pFile.exists() && !pFile.canWrite())))) {
(new PrintToFileErrorDialog(ownerFrame,
ServiceDialog.getMsg("dialog.owtitle"),
ServiceDialog.getMsg("dialog.writeerror")+" "+fullName,
ServiceDialog.getMsg("button.ok"))).setVisible(true);
fileDialog.setVisible(true);
fileName = fileDialog.getFile();
if (fileName == null) {
fileDialog.dispose();
return false;
}
fullName = fileDialog.getDirectory() + fileName;
f = new File(fullName);
pFile = f.getParentFile();
}
fileDialog.dispose();
attributes.add(new Destination(f.toURI()));
return true;
}
}
开发者ID:campolake,项目名称:openjdk9,代码行数:82,代码来源:WPrinterJob.java
注:本文中的sun.print.ServiceDialog类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论