printdialog1.java

来自「这是用SWT程序写的对话框程序Dialog视图」· Java 代码 · 共 28 行

JAVA
28
字号
/**
 * @作者:陈刚
 * @Email:glchengang@yeah.net
 * @Blog:http://blog.csdn.net/glchengang
 */
package jface.dialog.other;

import org.eclipse.swt.printing.PrintDialog;
import org.eclipse.swt.printing.Printer;
import org.eclipse.swt.printing.PrinterData;
import org.eclipse.swt.widgets.Shell;

public class PrintDialog1 {

    public static void main(String[] args) {
        final Shell shell = new Shell();

        PrintDialog dlg = new PrintDialog(shell);
        PrinterData printerData = dlg.open();
        if (printerData != null) {
            Printer printer = new Printer(printerData);
            //使用printer对象... ...
            //一定要记得用完后,调用printer.dispose()将printer释放掉
        }

    }

}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?