小编Tho*_*mas的帖子

Java/Javascript将包含applet的浏览器窗口带到前台

有没有办法从Java applet警报窗口将浏览器窗口拉到前台/焦点?我在一个html页面中有一个小程序,它会显示一个带有按钮的警报.当按下按钮时,我希望原始浏览器窗口从任何地方弹出(最小化,覆盖等).我相信有一种方法可以将Java连接到Javascript来执行此操作,但我不知道Javascript.

这是Java applet代码:

/** An applet that posts an alert and waits for the alert button to be pressed.
* Version 1 uses http://java.sun.com/products/plugin/1.3/docs/jsobject.html
*/

import netscape.javascript.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class Bounce extends JApplet implements ActionListener {
    JDialog dialog;
    JSObject window;
    String message;

    public void paint(Graphics g) {
        g.clearRect(0,0, 400,40);
        g.drawString(message,40,20);
    }

    public void init() {
        JFrame frame= null;
        dialog= new JDialog(frame, "Bounce App");

        JButton setupButton= new JButton("Bounce it back!");
        setupButton.addActionListener(this);

        JPanel contentPane= new JPanel(); …
Run Code Online (Sandbox Code Playgroud)

javascript java browser focus window

8
推荐指数
1
解决办法
780
查看次数

标签 统计

browser ×1

focus ×1

java ×1

javascript ×1

window ×1