本文整理了Java中java.awt.Window.getPreferredSize()
方法的一些代码示例,展示了Window.getPreferredSize()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Window.getPreferredSize()
方法的具体详情如下:
包路径:java.awt.Window
类名称:Window
方法名:getPreferredSize
暂无
代码示例来源:origin: stackoverflow.com
private void adjustWindowSize(ContainerWrapper parent) {
BoundSize wBounds = lc.getPackWidth();
BoundSize hBounds = lc.getPackHeight();
if (wBounds == null && hBounds == null)
return;
Window win = ((Window) SwingUtilities.getAncestorOfClass(Window.class,
(Component) parent.getComponent()));
if (win == null)
return;
Dimension prefSize = win.getPreferredSize();
....
}
代码示例来源:origin: org.jrobin/jrobin
static void centerOnScreen(Window window) {
Toolkit t = Toolkit.getDefaultToolkit();
Dimension screenSize = t.getScreenSize();
Dimension frameSize = window.getPreferredSize();
double x = (screenSize.getWidth() - frameSize.getWidth()) / 2;
double y = (screenSize.getHeight() - frameSize.getHeight()) / 2;
window.setLocation((int) x, (int) y);
}
代码示例来源:origin: org.fusesource.rrd4j/rrd4j
static void centerOnScreen(Window window) {
Toolkit t = Toolkit.getDefaultToolkit();
Dimension screenSize = t.getScreenSize();
Dimension frameSize = window.getPreferredSize();
double x = (screenSize.getWidth() - frameSize.getWidth()) / 2;
double y = (screenSize.getHeight() - frameSize.getHeight()) / 2;
window.setLocation((int) x, (int) y);
}
代码示例来源:origin: org.fudaa.framework.ctulu/ctulu-ui
static void centerWindowInScreen(final Window window) {
final Dimension screenSize= window.getToolkit().getScreenSize();
final Dimension windowSize= window.getPreferredSize();
window.setLocation(
(int) (screenSize.getWidth() / 2 - windowSize.getWidth() / 2),
(int) (screenSize.getHeight() / 2 - windowSize.getHeight() / 2));
}
/**
代码示例来源:origin: Baralga/baralga
/**
* Ensures that a window stays within the current screen's bounds
* while changing the position of the window as little as possible.
*
* @param preferredLeftTop The preferred left-top location of the window
* @param window The window
*/
public static void keepInScreenBounds(final Point preferredLeftTop, final Window window) {
final Rectangle preferredBounds = new Rectangle(
preferredLeftTop,
window.getPreferredSize()
);
window.setLocation(
ScreenUtils.ensureOnScreen(preferredBounds).getLocation()
);
}
代码示例来源:origin: org.opentcs.thirdparty.jhotdraw/jhotdraw
screenBounds.height -= screenInsets.top + screenInsets.bottom;
Dimension preferredSize = window.getPreferredSize();
代码示例来源:origin: org.opentcs.thirdparty.jhotdraw/jhotdraw
screenBounds.height -= screenInsets.top + screenInsets.bottom;
window.pack();
Dimension preferredSize = window.getPreferredSize();
代码示例来源:origin: org.appdapter/org.appdapter.lib.gui
window.setSize(window.getPreferredSize());
org.appdapter.gui.browse.Utility.centerWindow(window);
if (showASAP) {
内容来源于网络,如有侵权,请联系作者删除!