本文整理了Java中java.awt.Window.getParent()
方法的一些代码示例,展示了Window.getParent()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Window.getParent()
方法的具体详情如下:
包路径:java.awt.Window
类名称:Window
方法名:getParent
暂无
代码示例来源:origin: com.numdata/numdata-swing
/**
* Centers the given window on its parent window or, if it has no parent, on
* the screen.
*
* @param window Window to be centered.
*/
public static void centerOnParent( @NotNull final Window window )
{
centerOnComponent( window, window.getParent() );
}
代码示例来源:origin: org.bitbucket.goalhub.simpleide/jedit
/**
* Loads a windows's geometry from the properties.
* The geometry is loaded from the <code><i>name</i>.x</code>,
* <code><i>name</i>.y</code>, <code><i>name</i>.width</code> and
* <code><i>name</i>.height</code> properties.
*
* @param win The window to load geometry from
* @param name The name of the window
*/
public static void loadGeometry(Window win, String name)
{
loadGeometry(win, win.getParent(), name);
} //}}}
代码示例来源:origin: org.bitbucket.goalhub.simpleide/jedit
/**
* Saves a window's geometry to the properties.
* The geometry is saved to the <code><i>name</i>.x</code>,
* <code><i>name</i>.y</code>, <code><i>name</i>.width</code> and
* <code><i>name</i>.height</code> properties.<br />
* For Frame's and descendents use {@link #addSizeSaver(Frame,String)} to save the sizes
* correct even if the Frame is in maximized or iconified state.
* @param win The window to load geometry from
* @param name The name of the window
* @see #addSizeSaver(Frame,String)
*/
public static void saveGeometry(Window win, String name)
{
saveGeometry (win, win.getParent(), name);
} //}}}
代码示例来源:origin: org.jspresso/jspresso-swing-components
/**
* Gets the visible parent window.
*
* @param component
* the component to start from
* @return the visible parent window or null.
*/
public static Window getVisibleWindow(Component component) {
if (component instanceof JWindow) {
return (JWindow) component;
}
Window w = SwingUtilities.getWindowAncestor(component);
if (w != null && !w.isVisible() && w.getParent() != null) {
return getVisibleWindow(w.getParent());
}
return w;
}
代码示例来源:origin: com.jidesoft/jide-oss
/**
* Center the component to it's parent window.
*
* @param childToCenter the parent window
*/
public static void centerWindow(Window childToCenter) {
childToCenter.setLocationRelativeTo(childToCenter.getParent());
// Container parentWindow = childToCenter.getParent();
//
// int width = (parentWindow.getWidth() - childToCenter.getWidth()) >> 1;
// int height = (parentWindow.getHeight() - childToCenter.getHeight()) >> 1;
//
// // according to javadoc of setLocation, it's relevant to parent window. but it's not the case.
// Point location = parentWindow.getLocation();
// width += location.x;
// height += location.y;
// childToCenter.setLocation(width, height);
}
代码示例来源:origin: org.jspresso.framework/jspresso-swing-components
/**
* Gets the visible parent window.
*
* @param component
* the component to start from
* @return the visible parent window or null.
*/
public static Window getVisibleWindow(Component component) {
if (component instanceof JWindow) {
return (JWindow) component;
}
Window w = SwingUtilities.getWindowAncestor(component);
if (w != null && !w.isVisible() && w.getParent() != null) {
return getVisibleWindow(w.getParent());
}
return w;
}
代码示例来源:origin: joel-costigliola/assertj-swing
private void filterIfParentIsFiltered(@Nonnull Window w) {
if (!filter.isIgnored(w.getParent())) {
return;
}
filter.ignore(w);
}
}
代码示例来源:origin: abbot/abbot
/** Return the {@link Frame} corresponding to the given object. */
public static Frame getFrame(Object o) {
Window w = getWindow(o);
while (!(w instanceof Frame) && w != null) {
w = (Window)w.getParent();
}
return w instanceof Frame ? (Frame)w : JOptionPane.getRootFrame();
}
代码示例来源:origin: atdl4j/atdl4j
/**
* Returns getParentComposite().getShell().
* @return the shell
*/
private Window getShell()
{
if ( getParentComposite() != null )
{
return (Window)getParentComposite().getParent();
}
else
{
return null;
}
}
代码示例来源:origin: org.eclipse.platform/org.eclipse.swt.gtk.aix.ppc
@Override
public void eventDispatched(AWTEvent event) {
if (event.getID() == WindowEvent.WINDOW_OPENED) {
final Window window = (Window) event.getSource();
if (window.getParent() == frame) {
parent.getDisplay().asyncExec(new Runnable() {
@Override
public void run() {
if (parent.isDisposed()) return;
Shell shell = parent.getShell();
loadLibrary();
int /*long*/ awtHandle = getAWTHandle(window);
if (awtHandle == 0) return;
int /*long*/ xWindow;
if (OS.GTK3) {
xWindow = OS.gdk_x11_window_get_xid (OS.gtk_widget_get_window (shell.handle));
} else {
xWindow = OS.gdk_x11_drawable_get_xid(OS.gtk_widget_get_window(OS.gtk_widget_get_toplevel(shell.handle)));
}
OS.XSetTransientForHint(OS.gdk_x11_display_get_xdisplay(OS.gdk_display_get_default()), awtHandle, xWindow);
}
});
}
}
}
};
代码示例来源:origin: org.eclipse.platform/org.eclipse.swt.gtk.linux.ppc
@Override
public void eventDispatched(AWTEvent event) {
if (event.getID() == WindowEvent.WINDOW_OPENED) {
final Window window = (Window) event.getSource();
if (window.getParent() == frame) {
parent.getDisplay().asyncExec(new Runnable() {
@Override
public void run() {
if (parent.isDisposed()) return;
Shell shell = parent.getShell();
loadLibrary();
int /*long*/ awtHandle = getAWTHandle(window);
if (awtHandle == 0) return;
int /*long*/ xWindow;
if (OS.GTK3) {
xWindow = OS.gdk_x11_window_get_xid (OS.gtk_widget_get_window (shell.handle));
} else {
xWindow = OS.gdk_x11_drawable_get_xid(OS.gtk_widget_get_window(OS.gtk_widget_get_toplevel(shell.handle)));
}
OS.XSetTransientForHint(OS.gdk_x11_display_get_xdisplay(OS.gdk_display_get_default()), awtHandle, xWindow);
}
});
}
}
}
};
代码示例来源:origin: org.eclipse.platform/org.eclipse.swt.gtk.linux.s390x
@Override
public void eventDispatched(AWTEvent event) {
if (event.getID() == WindowEvent.WINDOW_OPENED) {
final Window window = (Window) event.getSource();
if (window.getParent() == frame) {
parent.getDisplay().asyncExec(new Runnable() {
@Override
public void run() {
if (parent.isDisposed()) return;
Shell shell = parent.getShell();
loadLibrary();
long /*int*/ awtHandle = getAWTHandle(window);
if (awtHandle == 0) return;
long /*int*/ xWindow;
if (OS.GTK3) {
xWindow = OS.gdk_x11_window_get_xid (OS.gtk_widget_get_window (shell.handle));
} else {
xWindow = OS.gdk_x11_drawable_get_xid(OS.gtk_widget_get_window(OS.gtk_widget_get_toplevel(shell.handle)));
}
OS.XSetTransientForHint(OS.gdk_x11_display_get_xdisplay(OS.gdk_display_get_default()), awtHandle, xWindow);
}
});
}
}
}
};
代码示例来源:origin: stackoverflow.com
final Component parent = ancestor.getParent ();
if ( parent != null && parent instanceof Window && parent.getBackground ().getAlpha () == 0 )
代码示例来源:origin: stackoverflow.com
public static void showOnScreen(Window frame) {
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice[] gd = ge.getScreenDevices();
final GraphicsDevice frameDevice = frame.getParent().getGraphicsConfiguration().getDevice();
for (GraphicsDevice graphicsDevice : gd) {
if (frameDevice.equals(graphicsDevice) || frameDevice.getIDstring().equals(graphicsDevice.getIDstring())) {
final Rectangle monitorBounds = graphicsDevice.getDefaultConfiguration().getBounds();
final int x = monitorBounds.x + (monitorBounds.width - frame.getWidth()) /2;
final int y = monitorBounds.y + (monitorBounds.height - frame.getHeight()) / 2;
frame.setLocation(x, y);
}
}
}
代码示例来源:origin: org.bidib.org.oxbow/swingbits
while (pWnd != null && !pWnd.isVisible() && pWnd.getParent() != null) {
pWnd = (Window) pWnd.getParent();
代码示例来源:origin: eugener/oxbow
while (pWnd != null && !pWnd.isVisible() && pWnd.getParent() != null) {
pWnd = (Window) pWnd.getParent();
代码示例来源:origin: org.jspresso/jspresso-swing-components
/**
* Center a window on screen.
*
* @param w
* the window to center on screen.
*/
public static void centerInParent(Window w) {
Container parent = w.getParent();
if (parent != null) {
Dimension parentSize = parent.getSize();
w.setLocation(parent.getX() + (parentSize.width - w.getWidth()) / 2,
parent.getY() + (parentSize.height - w.getHeight()) / 2);
}
}
代码示例来源:origin: org.jspresso.framework/jspresso-swing-components
/**
* Center a window on screen.
*
* @param w
* the window to center on screen.
*/
public static void centerInParent(Window w) {
Container parent = w.getParent();
if (parent != null) {
Dimension parentSize = parent.getSize();
w.setLocation(parent.getX() + (parentSize.width - w.getWidth()) / 2,
parent.getY() + (parentSize.height - w.getHeight()) / 2);
}
}
代码示例来源:origin: abbot/abbot
else if (isFiltered(w.getParent())) {
Log.debug("Parent is filtered, filter " + w.getName());
setFiltered(w, true);
代码示例来源:origin: stackoverflow.com
@Wire
private Window menu;
@Wire
private Listbox box;
private Listhead lHead;
@Override
public void doAfterCompose(Component comp) throws Exception {
super.doAfterCompose(comp);
// get the Listboxhead in which we like to change the the col order
lHead = (Listhead) menu.getParent().query("#lbox > #lHead");
// set the model for Listbox box in the pop up
box.setModel(new ListModelList<>(lHead.getChildren()));
}
@Listen("onDrop = listitem")
public void onDropInMenu(DropEvent ev) {
// get the draged and dropped again
Listitem dragged = (Listitem) ev.getDragged();
Listitem droppedOn = (Listitem) ev.getTarget();
// then get their indexes.
int from = box.getItems().indexOf(dragged);
int to = box.getItems().indexOf(droppedOn);
// swap the positions
lHead.insertBefore(lHead.getChildren().get(from), lHead.getChildren().get(to));
// swap related Listcell in all Listitem instances
for (Listitem item : lHead.getListbox().getItems()) {
item.insertBefore(item.getChildren().get(from), item.getChildren().get(to));
}
// swap the items in pop up Lisbox as well
box.insertBefore(dragged, droppedOn);
}
内容来源于网络,如有侵权,请联系作者删除!