本文整理了Java中java.awt.Window.getInsets()
方法的一些代码示例,展示了Window.getInsets()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Window.getInsets()
方法的具体详情如下:
包路径:java.awt.Window
类名称:Window
方法名:getInsets
暂无
代码示例来源:origin: JetBrains/ideavim
final Point windowPos = window.getLocation();
pos.translate(windowPos.x, windowPos.y);
final Insets windowInsets = window.getInsets();
pos.translate(windowInsets.left, windowInsets.top);
bounds.setLocation(pos);
代码示例来源:origin: de.sciss/scisslib
public Insets getInsets()
{
if( w != null ) {
return w.getInsets();
} else if( jif != null ) {
return jif.getInsets();
} else {
throw new IllegalStateException();
}
}
代码示例来源:origin: khuxtable/seaglass
/**
* Get the parent insets.
*
* @return the insets.
*/
private Insets getParentInsets() {
if (rootParent instanceof JApplet) {
return ((JApplet) rootParent).getInsets();
}
return ((Window) rootParent).getInsets();
}
代码示例来源:origin: org.swinglabs.swingx/swingx-all
/**
* <p/>
* Returns the <code>Point</code> at which a window should be placed in
* order to be staggered slightly from another "origin" window to
* ensure that the title areas of both windows remain visible to the user.
* </p>
*
* @param originWindow Window from which the staggered location will be calculated
*
* @return location staggered from the upper left location of the origin
* window
*/
public static Point getPointForStaggering(Window originWindow) {
Point origin = originWindow.getLocation();
Insets insets = originWindow.getInsets();
origin.x += insets.top;
origin.y += insets.top;
return origin;
}
代码示例来源:origin: tmyroadctfig/swingx
/**
* <p/>
* Returns the <code>Point</code> at which a window should be placed in
* order to be staggered slightly from another "origin" window to
* ensure that the title areas of both windows remain visible to the user.
* </p>
*
* @param originWindow Window from which the staggered location will be calculated
*
* @return location staggered from the upper left location of the origin
* window
*/
public static Point getPointForStaggering(Window originWindow) {
Point origin = originWindow.getLocation();
Insets insets = originWindow.getInsets();
origin.x += insets.top;
origin.y += insets.top;
return origin;
}
代码示例来源:origin: org.bidib.jbidib.swinglabs.swingx/swingx-common
/**
* <p/>
* Returns the <code>Point</code> at which a window should be placed in
* order to be staggered slightly from another "origin" window to
* ensure that the title areas of both windows remain visible to the user.
* </p>
*
* @param originWindow Window from which the staggered location will be calculated
*
* @return location staggered from the upper left location of the origin
* window
*/
public static Point getPointForStaggering(Window originWindow) {
Point origin = originWindow.getLocation();
Insets insets = originWindow.getInsets();
origin.x += insets.top;
origin.y += insets.top;
return origin;
}
代码示例来源:origin: org.codehaus.jtstand/jtstand-desktop
/**
* <p/>
* Returns the <code>Point</code> at which a window should be placed in
* order to be staggered slightly from another "origin" window to
* ensure that the title areas of both windows remain visible to the user.
* </p>
*
* @param originWindow Window from which the staggered location will be calculated
*
* @return location staggered from the upper left location of the origin
* window
*/
public static Point getPointForStaggering(Window originWindow) {
Point origin = originWindow.getLocation();
Insets insets = originWindow.getInsets();
origin.x += insets.top;
origin.y += insets.top;
return origin;
}
代码示例来源:origin: joel-costigliola/assertj-swing
@RunsInCurrentThread
private boolean shouldResize(@Nonnull Window window) {
Insets insets = window.getInsets();
int w = window.getWidth() - (insets.left + insets.right);
if (w < MINIMUM_WINDOW_SIZE.width) {
return true;
}
int h = window.getHeight() - (insets.top + insets.bottom);
return h < MINIMUM_WINDOW_SIZE.height;
}
代码示例来源:origin: ch.unibas.cs.gravis/scalismo-native-stub
/**
* Return insets of the component w/o traversing up to parent,
* i.e. trying Window and JComponent.
* <p>
* Exception is JRootPane.
* Return it's parent's Window component's insets if available,
* otherwise return JRootPane's insets.<br>
* This is due to <i>experience</i> that <i>some</i> JRootPane's
* do not expose valid insets value.
* </p>
* @param topLevelOnly if true only returns insets of top-level components, i.e. Window and JRootPanel,
* otherwise for JComponent as well.
*/
public static Insets getInsets(final Component c, final boolean topLevelOnly) {
if( c instanceof Window ) {
return ((Window)c).getInsets();
}
if( c instanceof JRootPane ) {
final Window w = getWindow(c);
if( null != w ) {
return w.getInsets();
}
return ((JRootPane)c).getInsets();
}
if( !topLevelOnly && c instanceof JComponent ) {
return ((JComponent)c).getInsets();
}
return null;
}
代码示例来源: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: stackoverflow.com
public static void makeSheet(Dialog dialog) {
dialog.addNotify();
ComponentPeer peer = dialog.getPeer();
// File dialogs are CFileDialog instead. Unfortunately this means this hack
// can't work for those. :(
if (peer instanceof LWWindowPeer) {
LWWindowPeer windowPeer = (LWWindowPeer) dialog.getPeer();
//XXX: Should check this before casting too.
CPlatformWindow platformWindow = (CPlatformWindow) windowPeer.getPlatformWindow();
try {
Method method = CPlatformWindow.class.getDeclaredMethod(
"setStyleBits", int.class, boolean.class);
method.setAccessible(true);
method.invoke(platformWindow, 64 /* CPlatformWindow.SHEET */, true);
Window parent = dialog.getOwner();
dialog.setLocation(dialog.getLocation().x,
parent.getLocation().y + parent.getInsets().top);
} catch (Exception e) {
Logger.getLogger(SheetHack.class.getName())
.log(Level.WARNING, "Couldn't call setStyleBits", e);
}
}
}
代码示例来源:origin: org.apache.pivot/pivot-wtk
/**
* Sizes the window's native host frame to match its preferred size.
*
* @param window
*/
public static void sizeHostToFit(Window window) {
if (window == null) {
throw new IllegalArgumentException();
}
if (isFullScreen()) {
throw new IllegalStateException();
}
Dimensions size = window.getPreferredSize();
java.awt.Window hostWindow = window.getDisplay().getHostWindow();
java.awt.Insets frameInsets = hostWindow.getInsets();
hostWindow.setSize(size.width + (frameInsets.left + frameInsets.right),
size.height + (frameInsets.top + frameInsets.bottom));
}
代码示例来源:origin: com.barchart.pivot/pivot-wtk
/**
* Sizes the window's native host frame to match its preferred size.
*
* @param window
*/
public static void sizeHostToFit(Window window) {
if (window == null) {
throw new IllegalArgumentException();
}
if (isFullScreen()) {
throw new IllegalStateException();
}
Dimensions size = window.getPreferredSize();
java.awt.Window hostWindow = window.getDisplay().getHostWindow();
java.awt.Insets frameInsets = hostWindow.getInsets();
hostWindow.setSize(size.width + (frameInsets.left + frameInsets.right),
size.height + (frameInsets.top + frameInsets.bottom));
}
代码示例来源:origin: khuxtable/seaglass
/**
* Returns the corner that contains the point <code>x</code>, <code>
* y</code>, or -1 if the position doesn't match a corner.
*
* @param w the window.
* @param x the x coordinate.
* @param y the y coordinate.
*
* @return the corner containing the (x, y) coordinate, or -1 if the
* position doesn't match a corner.
*/
private int calculateCorner(Window w, int x, int y) {
Insets insets = w.getInsets();
int xPosition = calculatePosition(x - insets.left, w.getWidth() - insets.left - insets.right);
int yPosition = calculatePosition(y - insets.top, w.getHeight() - insets.top - insets.bottom);
if (xPosition == -1 || yPosition == -1) {
return -1;
}
return yPosition * 5 + xPosition;
}
代码示例来源:origin: com.github.insubstantial/substance
/**
* Returns the corner that contains the point <code>x</code>,
* <code>y</code>, or -1 if the position doesn't match a corner.
*
* @param w
* Window.
* @param x
* X coordinate.
* @param y
* Y coordinate.
* @return Corner that contains the specified point.
*/
private int calculateCorner(Window w, int x, int y) {
Insets insets = w.getInsets();
int xPosition = this.calculatePosition(x - insets.left, w
.getWidth()
- insets.left - insets.right);
int yPosition = this.calculatePosition(y - insets.top, w
.getHeight()
- insets.top - insets.bottom);
if ((xPosition == -1) || (yPosition == -1)) {
return -1;
}
return yPosition * 5 + xPosition;
}
代码示例来源:origin: org.java.net.substance/substance
/**
* Returns the corner that contains the point <code>x</code>,
* <code>y</code>, or -1 if the position doesn't match a corner.
*
* @param w
* Window.
* @param x
* X coordinate.
* @param y
* Y coordinate.
* @return Corner that contains the specified point.
*/
private int calculateCorner(Window w, int x, int y) {
Insets insets = w.getInsets();
int xPosition = this.calculatePosition(x - insets.left, w
.getWidth()
- insets.left - insets.right);
int yPosition = this.calculatePosition(y - insets.top, w
.getHeight()
- insets.top - insets.bottom);
if ((xPosition == -1) || (yPosition == -1)) {
return -1;
}
return yPosition * 5 + xPosition;
}
代码示例来源:origin: org.opentcs.thirdparty.jhotdraw/jhotdraw
@Override
public void componentMoved(ComponentEvent evt) {
Window owner = getOwner();
Point newLocation = owner.getLocation();
if (!newLocation.equals(oldLocation)) {
setLocation(
newLocation.x + (owner.getWidth() - getWidth()) / 2,
newLocation.y + owner.getInsets().top);
shiftBackLocation = null;
oldLocation = newLocation;
}
}
};
代码示例来源:origin: stackoverflow.com
@Override
public void paint(Graphics g)
{
checkResizeWindow(this);
super.paint(g);
}
public static void checkResizeWindow(Window window)
{
if (!window.isShowing())
{
return;
}
Component[] components = window.getComponents();
if (components.length == 0)
{
return;
}
Component comp = components[0];
Insets insets = window.getInsets();
Dimension innerSize = window.getSize();
innerSize.width -= insets.left + insets.right;
innerSize.height -= insets.top + insets.bottom;
if (!innerSize.equals(comp.getSize()))
{
window.invalidate();
window.validate();
}
}
代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/napkinlaf
rect.x = window.getWidth() - window.getInsets().right - 2;
代码示例来源:origin: org.opentcs.thirdparty.jhotdraw/jhotdraw
sheetLoc = new Point(
ownerLoc.x + (owner.getWidth() - getWidth()) / 2,
ownerLoc.y + owner.getInsets().top + ((JFrame) owner).getRootPane().getContentPane().getY());
} else if (owner instanceof JDialog) {
sheetLoc = new Point(
ownerLoc.x + (owner.getWidth() - getWidth()) / 2,
ownerLoc.y + owner.getInsets().top + ((JDialog) owner).getRootPane().getContentPane().getY());
} else {
sheetLoc = new Point(
ownerLoc.x + (owner.getWidth() - getWidth()) / 2,
ownerLoc.y + owner.getInsets().top);
内容来源于网络,如有侵权,请联系作者删除!