标签:最大 min system try cond amp 最小 界面 scree
1Platform常用方法有exit()、runlater()、isSupported()
exit():
1 Stage stage = new Stage(); 2 Stage stage1 = new Stage(); 3 Stage stage2 = new Stage(); 4 stage.show(); 5 stage1.show(); 6 stage2.show(); 7 Platform.exit ();//退出所有的界面
runLater():
System.out.println("Runnable外的线程 "+Thread.currentThread().getName()); //Runnable外的线程 JavaFX Application Thread Platform.runLater(new Runnable() { @Override public void run() { while(true){ try { Thread.sleep(1000); System.out.println("Runnable内的线程"+Thread.currentThread().getName()); //Runnable内的线程JavaFX Application Thread }catch (InterruptedException e){ } }} });System.out.println("123");//先执行Runnable外的然后再执行Runnnable里的
isSupported():
Platform.isSupported(ConditionalFeature.CONTROLS);//检测是否具有运行该控件的环境
Screen:主要的方法是查看屏幕硬件参数:
//getPrimary()返回主屏幕 System.out.println("实际屏幕宽度:"+Screen.getPrimary().getBounds().getWidth()); System.out.println("实际屏幕高度:"+Screen.getPrimary().getBounds().getHeight()); //以左上角为X=0,Y=0 Y向下递增 X向右递增 System.out.println("屏幕最小X:"+Screen.getPrimary().getBounds().getMinX()+ "屏幕最大X:"+Screen.getPrimary().getBounds().getMaxX()); System.out.println("屏幕最小Y:"+Screen.getPrimary().getBounds().getMinY()+ "屏幕最大Y:"+Screen.getPrimary().getBounds().getMaxY()); System.out.println("可见屏幕高度:"+Screen.getPrimary().getVisualBounds().getHeight()); System.out.println("可见屏幕高度:"+Screen.getPrimary().getVisualBounds().getHeight()); System.out.println("可见屏幕最小X:"+Screen.getPrimary().getVisualBounds().getMinX()+ "可见屏幕最大X:"+Screen.getPrimary().getVisualBounds().getMaxX()); System.out.println("可见屏幕最小Y:"+Screen.getPrimary().getVisualBounds().getMinY()+ "可见屏幕最大Y:"+Screen.getPrimary().getVisualBounds().getMaxY()); System.out.println("屏幕DPI:"+Screen.getPrimary().getDpi()); System.out.println("屏幕列表:"+Screen.getScreens());
补充:Platform的setImplictExit()方法用于设置当界面关闭时程序是否终止
Platform.setImplicitExit(false);//即界面关闭时程序不会终止 Platform.setImpliatExit(true);//界面关闭时程序终止
标签:最大 min system try cond amp 最小 界面 scree
原文地址:https://www.cnblogs.com/yanquebbuyan/p/9977065.html