本文整理了Java中java.awt.Window.toFront()
方法的一些代码示例,展示了Window.toFront()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Window.toFront()
方法的具体详情如下:
包路径:java.awt.Window
类名称:Window
方法名:toFront
[英]If this Window is visible, brings this Window to the front and may make it the focused Window.
Places this Window at the top of the stacking order and shows it in front of any other Windows in this VM. No action will take place if this Window is not visible. Some platforms do not allow Windows which own other Windows to appear on top of those owned Windows. Some platforms may not permit this VM to place its Windows above windows of native applications, or Windows of other VMs. This permission may depend on whether a Window in this VM is already focused. Every attempt will be made to move this Window as high as possible in the stacking order; however, developers should not assume that this method will move this Window above all other windows in every situation.
Because of variations in native windowing systems, no guarantees about changes to the focused and active Windows can be made. Developers must never assume that this Window is the focused or active Window until this Window receives a WINDOW_GAINED_FOCUS or WINDOW_ACTIVATED event. On platforms where the top-most window is the focused window, this method will probably focus this Window, if it is not already focused. On platforms where the stacking order does not typically affect the focused window, this method will probably leave the focused and active Windows unchanged.
If this method causes this Window to be focused, and this Window is a Frame it will also become activated. If this Window is focused, but it is not a Frame then the first Frame that is an owner of this Window will be activated.
[中]如果此窗口可见,则将此窗口带到前面,并可能使其成为聚焦窗口。
将此窗口放置在堆叠顺序的顶部,并将其显示在此VM中的任何其他窗口前面。如果此窗口不可见,则不会执行任何操作。有些平台不允许拥有其他窗口的窗口出现在那些拥有的窗口之上。某些平台可能不允许此VM将其窗口置于本机应用程序的窗口或其他VM的窗口之上。此权限可能取决于此VM中的窗口是否已聚焦。将尽一切努力按照堆叠顺序将该窗口移动到尽可能高的位置;然而,开发人员不应该假设这种方法在任何情况下都会将此窗口移动到所有其他窗口之上。
由于本机窗口系统的变化,无法保证对聚焦窗口和活动窗口进行更改。在该窗口接收到“已获得焦点”或“窗口已激活”事件之前,开发人员决不能假定该窗口是聚焦或活动窗口。在最上面的窗口是聚焦窗口的平台上,如果该窗口尚未聚焦,该方法可能会聚焦该窗口。在堆叠顺序通常不会影响聚焦窗口的平台上,此方法可能会保持聚焦窗口和活动窗口不变。
如果此方法导致此窗口聚焦,并且此窗口是一个帧,则它也将被激活。如果此窗口已聚焦,但它不是一个帧,则此窗口的所有者的第一个帧将被激活。
代码示例来源:origin: stackoverflow.com
if (suggestionsPanel.getComponent(i) instanceof SuggestionLabel) {
((SuggestionLabel) suggestionsPanel.getComponent(i)).setFocused(true);
autoSuggestionPopUpWindow.toFront();
autoSuggestionPopUpWindow.requestFocusInWindow();
suggestionsPanel.requestFocusInWindow();
if (i < max) {
sl.setFocused(true);
autoSuggestionPopUpWindow.toFront();
autoSuggestionPopUpWindow.requestFocusInWindow();
suggestionsPanel.requestFocusInWindow();
container.toFront();
container.requestFocusInWindow();
textField.requestFocusInWindow();
代码示例来源:origin: net.sf.jt400/jt400
/**
* Attempts to send the find dialog to the front of the screen.
*/
public void toFront() {
find.toFront();
}
代码示例来源:origin: abbot/abbot
public void run() {
win.toFront();
win.toFront();
}
});
代码示例来源:origin: de.richtercloud/flexdock-core
public void toFront() {
Component root = getRootContainer();
if (root instanceof JFrame) {
((Window) root).toFront();
} else if (root instanceof JWindow) {
((Window) root).toFront();
} else if (root instanceof JDialog) {
((Window) root).toFront();
}
}
代码示例来源:origin: net.sf.squirrel-sql/squirrel-sql
public void run()
{
win.toFront();
win.setVisible(true);
}
});
代码示例来源:origin: net.sourceforge.mydoggy/mydoggy-plaf
public void windowLostFocus(WindowEvent e) {
end = System.currentTimeMillis();
long elapsed = end - start;
//System.out.println(elapsed);
if (elapsed < 100)
window.toFront();
window.removeWindowFocusListener(this);
}
}
代码示例来源:origin: org.jclarion/clarion-runtime
@Override
public void windowOpened(WindowEvent e) {
e.getWindow().toFront();
}
});
代码示例来源:origin: pentaho/pentaho-reporting
/**
* Invoked when a window has been opened.
*/
public void windowOpened( final WindowEvent e ) {
e.getWindow().toFront();
}
}
代码示例来源:origin: stackoverflow.com
java.awt.Dialog awtDialog = ...
Shell shell = new Shell(parent, SWT.APPLICATION_MODAL | SWT.NO_TRIM);
shell.setSize(0, 0);
shell.addFocusListener(new FocusAdapter() {
public void focusGained(FocusEvent e) {
awtDialog.requestFocus();
awtDialog.toFront();
}
});
代码示例来源:origin: realXuJiang/bigtable-sql
public void run()
{
win.toFront();
win.setVisible(true);
}
});
代码示例来源:origin: net.sourceforge.mydoggy/mydoggy-plaf
public void mousePressed(MouseEvent ev) {
Point dragWindowOffset = ev.getPoint();
Component w = (Component) ev.getSource();
if (isWindow)
((Window) floatingContainer).toFront();
dragOffsetX = dragWindowOffset.x;
dragOffsetY = dragWindowOffset.y;
dragWidth = w.getWidth();
dragHeight = w.getHeight();
dragCursor = getCursor(calculateCorner(w, dragWindowOffset.x, dragWindowOffset.y));
}
代码示例来源:origin: stackoverflow.com
import javax.swing.JFrame;
public class NewClass1 {
public static void main(String[] args) {
JFrame frame = new JFrame("On Top");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(100, 100);
frame.setVisible(true);
frame.toFront();
}
}
代码示例来源:origin: triplea-game/triplea
private void closeAndReturn() {
SwingUtilities.invokeLater(() -> {
setVisible(false);
owner.toFront();
owner = null;
dispose();
});
}
代码示例来源:origin: joel-costigliola/assertj-swing
@RunsInEDT
private static void doMoveToFront(final @Nonnull Window w) {
execute(() -> w.toFront());
}
代码示例来源:origin: chatty/chatty
/**
* Brings all added windows to the front, without giving them focus.
*/
private void updateOnTop() {
for (final Window w : ontop) {
w.setAutoRequestFocus(false);
w.toFront();
w.setAutoRequestFocus(true);
}
}
代码示例来源:origin: org.codehaus.jtstand/jtstand-desktop
public void run() {
if (!tested) {
uninstall();
if (retry < 3) {
// try 3 times to regain the focus
Window w = JXLoginPane.this.getTLA();
if (w != null) {
w.toFront();
}
cot.runTest();
retry++;
}
}
}
});
代码示例来源:origin: joel-costigliola/assertj-swing
@RunsInEDT
static void activateWindow(final @Nonnull Window w) {
execute(() -> {
w.toFront();
w.requestFocusInWindow();
});
}
代码示例来源:origin: org.opentcs.thirdparty.jhotdraw/jhotdraw
@Override
protected void finished() {
view.setEnabled(true);
SwingUtilities.getWindowAncestor(view.getComponent()).toFront();
if (oldFocusOwner != null) {
oldFocusOwner.requestFocus();
}
}
});
代码示例来源:origin: org.opentcs.thirdparty.jhotdraw/jhotdraw
@Override
protected void finished() {
view.setEnabled(true);
SwingUtilities.getWindowAncestor(view.getComponent()).toFront();
if (oldFocusOwner != null) {
oldFocusOwner.requestFocus();
}
}
});
代码示例来源:origin: jdfekete/geneaquilt
public static void endLongComputation(Window window) {
computationCount--;
if (computationCount == 0) {
window.setCursor(Cursor.getDefaultCursor());
window.toFront();
computationMessageWindow.setVisible(false);
}
}
内容来源于网络,如有侵权,请联系作者删除!