
版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/wzq__janeGreen_/article/details/79981382
Display.getDefault(): 该方法会返回用户图形界面线程中的Display实例,不管当前线程是否是用户图形界面线程.如果这个实例不存在,默认创建一个用户图形界面线程中的Display实例.
Display.getCurrent(): 返回当前线程中的Display实例.如果这是一个图形界面线程,实例非空;如果当前线程不是一个图形界面线程,则实例为空.
- /**
- * Returns the default display. One is created (making the thread that
- * invokes this method its user-interface thread) if it did not already
- * exist.
- *
- * @return the default display
- */
- public static Display getDefault()
- {
- synchronized (Device.class)
- {
- if (Default == null)
- Default = new Display();
- return Default;
- }
- }
Display.getCurrent(): 返回当前线程中的Display实例.如果这是一个图形界面线程,实例非空;如果当前线程不是一个图形界面线程,则实例为空.
- /**
- * Returns the display which the currently running thread is the
- * user-interface thread for, or null if the currently running thread is not
- * a user-interface thread for any display.
- *
- * @return the current display
- */
- public static Display getCurrent()
- {
- return findDisplay(Thread.currentThread());
- }
- 上一篇 java连接金仓数据库方法笔记
- 下一篇 SWT中为Text组件添加键盘回车事件
查看评论