本文整理了Java中java.awt.Window.getHeight()
方法的一些代码示例,展示了Window.getHeight()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Window.getHeight()
方法的具体详情如下:
包路径:java.awt.Window
类名称:Window
方法名:getHeight
暂无
代码示例来源:origin: stackoverflow.com
public static void centreWindow(Window frame) {
Dimension dimension = Toolkit.getDefaultToolkit().getScreenSize();
int x = (int) ((dimension.getWidth() - frame.getWidth()) / 2);
int y = (int) ((dimension.getHeight() - frame.getHeight()) / 2);
frame.setLocation(x, y);
}
代码示例来源:origin: skylot/jadx
public void saveWindowPos(Window window) {
WindowLocation pos = new WindowLocation(window.getClass().getSimpleName(),
window.getX(), window.getY(),
window.getWidth(), window.getHeight()
);
windowPos.put(pos.getWindowId(), pos);
partialSync(settings -> settings.windowPos = windowPos);
}
代码示例来源:origin: chewiebug/GCViewer
public void setVisible(boolean visible) {
if (visible) {
int x = (int) getOwner().getLocation().getX() + (getOwner().getWidth() / 2) - (getWidth() / 2);
int y = (int) getOwner().getLocation().getY() + (getOwner().getHeight() / 2) - (getHeight() / 2);
setLocation(adjustX(x), adjustY(y));
}
super.setVisible(visible);
}
代码示例来源:origin: nodebox/nodebox
public static void centerOnScreen(Window w, Window parent) {
Rectangle r = new Rectangle();
if (parent == null) {
r.setSize(Toolkit.getDefaultToolkit().getScreenSize());
} else {
r.setLocation(parent.getLocation());
r.setSize(parent.getSize());
}
// Determine the new location of the alert
int x = r.x + (r.width - w.getWidth()) / 2;
int y = r.y + (r.height - w.getHeight()) / 2;
// Move the alert
w.setLocation(x, y);
}
代码示例来源:origin: bobbylight/RSyntaxTextArea
/**
* Updates the font metrics the first time we're displayed.
*/
@Override
public void addNotify() {
super.addNotify();
// Some LookAndFeels (e.g. WebLaF) for some reason have a 0x0 parent
// window initially (perhaps something to do with them fading in?),
// which will cause an exception from getGraphics(), so we must be
// careful here.
if (metricsNeverRefreshed) {
Window parent = SwingUtilities.getWindowAncestor(this);
if (parent!=null && parent.getWidth()>0 && parent.getHeight()>0) {
refreshFontMetrics(getGraphics2D(getGraphics()));
metricsNeverRefreshed = false;
}
}
// Re-start parsing if we were removed from one container and added
// to another
if (parserManager!=null) {
parserManager.restartParsing();
}
}
代码示例来源:origin: bobbylight/RSyntaxTextArea
@Override
public void mouseDragged(MouseEvent e) {
Point newPos = e.getPoint();
SwingUtilities.convertPointToScreen(newPos, SizeGrip.this);
int xDelta = newPos.x - origPos.x;
int yDelta = newPos.y - origPos.y;
Window wind = SwingUtilities.getWindowAncestor(SizeGrip.this);
if (wind!=null) { // Should always be true
if (getComponentOrientation().isLeftToRight()) {
int w = wind.getWidth();
if (newPos.x>=wind.getX()) {
w += xDelta;
}
int h = wind.getHeight();
if (newPos.y>=wind.getY()) {
h += yDelta;
}
wind.setSize(w,h);
}
else { // RTL
int newW = Math.max(1, wind.getWidth()-xDelta);
int newH = Math.max(1, wind.getHeight()+yDelta);
wind.setBounds(newPos.x, wind.getY(), newW, newH);
}
// invalidate()/validate() needed pre-1.6.
wind.invalidate();
wind.validate();
}
origPos.setLocation(newPos);
}
代码示例来源:origin: apache/pdfbox
@Override
public void mouseClicked(MouseEvent e)
{
Window viewer = LogDialog.instance().getOwner();
// show the log window
LogDialog.instance().setSize(800, 400);
LogDialog.instance().setVisible(true);
LogDialog.instance().setLocation(viewer.getLocationOnScreen().x + viewer.getWidth() / 2,
viewer.getLocationOnScreen().y + viewer.getHeight() / 2);
}
});
代码示例来源:origin: org.bitbucket.goalhub.simpleide/jedit
private static Point fitInScreen(Point p, Window w, int lineHeight)
{
Rectangle screenSize = w.getGraphicsConfiguration().getBounds();
if(p.y + w.getHeight() >= screenSize.height)
p.y = p.y - w.getHeight() - lineHeight;
return p;
} //}}}
代码示例来源:origin: net.java.abeille/abeille
/**
* This method centers a window window and changes the width on the screen.
* The caller must pass the x percentages of screen width. The height
* remains unchanged
*/
public static void centerWindowChangeWidth(Window frame, float xpctWidth) {
float height = (float) frame.getHeight();
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
float pctheight = height / (float) screenSize.getHeight();
centerFrame(frame, xpctWidth, pctheight);
}
代码示例来源:origin: org.apache.cayenne.modeler/cayenne-modeler
@Override
public void componentResized(ComponentEvent e) {
setWidth(window.getWidth());
setHeight(window.getHeight());
}
});
代码示例来源:origin: org.apache.cayenne.modeler/cayenne-modeler
@Override
public void componentResized(ComponentEvent e) {
setWidth(window.getWidth());
setHeight(window.getHeight());
}
代码示例来源:origin: h3xstream/http-script-generator
private void centerWindow(Window frame) {
Dimension dimension = Toolkit.getDefaultToolkit().getScreenSize();
int x = (int) ((dimension.getWidth() - frame.getWidth()) / 2);
int y = (int) ((dimension.getHeight() - frame.getHeight()) / 2);
frame.setLocation(x, y);
}
代码示例来源:origin: jdfekete/geneaquilt
/**
* Centers a window on the primary display
*/
public static void centerOnPrimaryScreen(Window toplevel) {
Dimension screenRes = Toolkit.getDefaultToolkit().getScreenSize();
toplevel.setLocation((screenRes.width - toplevel.getWidth()) / 2,
(screenRes.height - toplevel.getHeight()) / 2);
}
代码示例来源:origin: xyz.cofe/gui.swing
@Override
public void recive(Window wnd) {
if( wnd==null )return;
int cw = wnd.getWidth();
int ch = wnd.getHeight();
if( cw<w || ch<h ){
int tw = Math.max(cw, w);
int th = Math.max(ch, h);
wnd.setSize(tw, th);
}
}
};
代码示例来源:origin: stackoverflow.com
public static void centreWindow(Window frame) {
Dimension dimension = Toolkit.getDefaultToolkit().getScreenSize();
int x = (int) ((dimension.getWidth() - frame.getWidth()) / 2);
int y = (int) ((dimension.getHeight() - frame.getHeight()) / 2);
frame.setLocation(x, y);
}
代码示例来源:origin: abbot/abbot
/** We can't get any motion events on an empty frame. */
private boolean isEmptyFrame(Window w) {
Insets insets = AWT.getInsets(w);
return insets.top + insets.bottom == w.getHeight()
|| insets.left + insets.right == w.getWidth();
}
}
代码示例来源:origin: org.gosu-lang.gosu/gosu-editor
public static void ensureWindowIsVisible( Window w )
{
int width = w.getWidth();
int height = w.getHeight();
Toolkit toolkit = Toolkit.getDefaultToolkit();
GraphicsConfiguration gc = w.getGraphicsConfiguration();
Insets screenInsets = toolkit.getScreenInsets( gc );
Rectangle screenSize = gc.getBounds();
w.setLocation( Math.max( screenInsets.left, Math.min( w.getX(), screenSize.width - screenInsets.right - width ) ),
Math.max( screenInsets.top, Math.min( w.getY(), screenSize.height - screenInsets.bottom - height ) ) );
}
代码示例来源:origin: joel-costigliola/assertj-swing
@RunsInCurrentThread
static @Nonnull Point absoluteCenterOf(@Nonnull Window window) {
Insets insets = window.getInsets();
int w = window.getWidth() - (insets.left + insets.right);
int h = window.getHeight() - (insets.top + insets.bottom);
int x = window.getX() + insets.left;
int y = window.getY() + insets.top;
return new Point(x + (w / 2), y + (h / 2));
}
代码示例来源:origin: robo-code/robocode
/**
* Packs, centers, and shows the specified window on the screen.
* @param window the window to pack, center, and show
* @param center {@code true} if the window must be centered; {@code false} otherwise
*/
private void packCenterShow(Window window, boolean center) {
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
window.pack();
if (center) {
window.setLocation((screenSize.width - window.getWidth()) / 2, (screenSize.height - window.getHeight()) / 2);
}
window.setVisible(true);
}
代码示例来源:origin: org.nuiton.jaxx/jaxx-widgets-about
public void display() {
setSize((int)(getOwner().getWidth() * 0.7), (int)(getOwner().getHeight() * 0.7));
SwingUtil.center(getOwner(), this);
setVisible(true);
}
内容来源于网络,如有侵权,请联系作者删除!