Java Tutorial/SWT/Device — различия между версиями
Admin (обсуждение | вклад) м (1 версия) |
(нет различий)
|
Текущая версия на 18:20, 31 мая 2010
17. List the display"s boundaries, client area
Device represents a physical device. It"s an abstract class, and has two concrete subclasses: Display and Printer.
<source lang="java">
import org.eclipse.swt.graphics.Device; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Shell; public class DeviceDisplayBoundary {
public static void main(String[] args) { final Display display = new Display(); final Shell shell = new Shell(display); Device device = shell.getDisplay(); System.out.println("getBounds(): "+ device.getBounds()); System.out.println("getClientArea(): " +device.getClientArea()); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
}</source>
17. List the display"s color depth, DPI
<source lang="java">
import org.eclipse.swt.graphics.Device; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Shell; public class DeviceDPI {
public static void main(String[] args) { final Display display = new Display(); final Shell shell = new Shell(display); Device device = shell.getDisplay(); System.out.println("getDepth(): " + device.getDepth()); System.out.println("getDPI(): " + device.getDPI()); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
}</source>
17. Whether or not it supports printing warnings
<source lang="java">
import org.eclipse.swt.graphics.Device; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Shell; public class PrintWarning {
public static void main(String[] args) { final Display display = new Display(); final Shell shell = new Shell(display); Device device = shell.getDisplay(); // By setting warnings to true and then getting warnings, we know if the // current platform supports it device.setWarnings(true); System.out.println("Warnings supported: " + device.getWarnings()); while (!shell.isDisposed()) { if (!display.readAndDispatch()) { display.sleep(); } } display.dispose(); }
}</source>