简体   繁体   English

如何在Applet中将Frame放在前面?

[英]How to bring Frame to front in applet?

I have an applet and a frame in it. 我有一个小程序和一个框架。 I want this frame to be opened when applet is launched. 我希望在启动applet时打开此框架。

public class MyApplet extends JApplet {
    public void init() {
        Frame frame = new JFrame("myframe");
        frame.setVisible(true);
        frame.toFront();
    }
}

This doesn't work. 这行不通。 Browser window is on top whereas frame is hidden. 浏览器窗口在顶部,而框架则隐藏。

Tried all that was written in How to bring a window to the front? 尝试了如何将窗口置于最前面的所有内容。

Try frame.setAlwaysOnTop(true) : 试试frame.setAlwaysOnTop(true)

Sets whether this window should always be above other windows. 设置此窗口是否应始终位于其他窗口之上。

The obvious solution is not to open the frame using an applet. 显而易见的解决方案是使用小程序打开框架。 Instead, launch the frame from a link using Java Web Start . 而是使用Java Web Start从链接启动框架。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM