[Original] SWING Tips .3: Set Window in the middle of the screen

xiaoxiao2021-03-06  43

[Original] the Swing technique .3: a window provided in the middle of the screen window is provided in the middle of the // screen, Window, Frame, Dialog, JWindow, JFrame, JDialogpublic static void setToScreenCenter (Window window) {Dimension screenSize = Toolkit.getDefaultToolkit () .getScreenSize (); Dimension windowSize = window.getSize (); if (windowSize.height> screenSize.height) windowSize.height = screenSize.height; if (windowSize.width> screenSize.width) windowSize.width = screenSize.width; Window.setLocation (Screensize.width-Windowsize.width) / 2, (Screensize.Height-Windowsize.Height) / 2);

转载请注明原文地址:https://www.9cbs.com/read-57289.html

New Post(0)