/
githubmirror
/
jdk21u
Обзор
Документация
Войти
/
githubmirror
/
jdk21u
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
test/jdk/java/awt/Dialog/PrintToFileTest/PrintToFileFrame.java
40 строк
1 KB
Goetz Lindenmaier
8340279: Open source several AWT Dialog tests - Batch 2
09 апр 2025, 17:57
09 апр 2025, 17:57
2b6eccc
Код
Авторство
О чём код?
import java.awt.Button; import java.awt.FlowLayout; import java.awt.Frame; import java.awt.PrintJob; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; class PrintToFileFrame extends Frame implements ActionListener { Button nativeDlg = new Button("Show print dialog"); public PrintToFileFrame() { this.setLayout(new FlowLayout()); add(nativeDlg); nativeDlg.addActionListener(this); setSize(300, 300); } @SuppressWarnings("removal") public void actionPerformed(ActionEvent ae) { if (System.getSecurityManager() == null) { throw new RuntimeException("Security manager isn't installed."); } try { System.getSecurityManager().checkPrintJobAccess(); System.out.println("checkPrintJobAccess - OK"); } catch (SecurityException e) { System.out.println("checkPrintJobAccess - ERROR " + e); } PrintJob printJob = getToolkit().getPrintJob(this, null, null); if (printJob != null) { System.out.println("Print Job: " + printJob); } else { System.out.println("Print Job is null."); } } }