/**
* Track a Window's position across application restarts; location is saved
* in a Preferences node that you pass in; we attach a ComponentListener to
* the Window.
*/
public static void monitorWindowPosition(
final Window w, final Preferences pNode) {
// Get the current saved position, if any
Point p = getSavedLocation(pNode);
int savedX = (int)p.getX();
int savedY = (int)p.getY();
if (savedX != -1) {
// Move window to is previous location
w.setLocation(savedX, savedY);
} else {
// Not saved yet, at least make it look nice
centre(w);
}
// Now make sure that if the user moves the window,
// we will save the new position.
w.addComponentListener(new ComponentAdapter() {
@Override
public void componentMoved(ComponentEvent e) {
setSavedLocation(pNode, w);
}
});
}
UtilGUI.java 文件源码
java
阅读 25
收藏 0
点赞 0
评论 0
项目:code-similarity
作者:
评论列表
文章目录