本文整理匯總了Java中java.awt.Window.getLocation方法的典型用法代碼示例。如果您正苦於以下問題:Java Window.getLocation方法的具體用法?Java Window.getLocation怎麽用?Java Window.getLocation使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.awt.Window
的用法示例。
在下文中一共展示了Window.getLocation方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: saveWindowLocation
import java.awt.Window; //導入方法依賴的package包/類
/**
* This static method can be used to save the window x,y, position (but not
* size). This statis method saves the window origin but not the size, based
* on a classname-based key in the supplied preferences node.
*
* @param window the window to save for
* @param prefs user preferences node
* @see #restoreWindowLocation
*/
public static void saveWindowLocation(Window window, Preferences prefs) {
String name = window.getClass().getName();
Point p = new Point(0, 0);
try {
p = window.getLocationOnScreen();
} catch (IllegalComponentStateException e) {
p = window.getLocation();
}
prefs.putInt(name + ".XPosition", (int) p.getX());
prefs.putInt(name + ".YPosition", (int) p.getY());
// log.info("saved location for window "+name);
}